LMInstantiator & UserPhrase // New method to check isFiltered().
This commit is contained in:
parent
ee11682edb
commit
0f2ad53481
|
@ -238,9 +238,8 @@ public extension vChewingLM {
|
|||
return result.isEmpty ? nil : result
|
||||
}
|
||||
|
||||
public func queryFilteredValue(key: String) -> [String]? {
|
||||
let result = lmFiltered.unigramsFor(key: key).map(\.value)
|
||||
return result.isEmpty ? nil : result
|
||||
public func isPairFiltered(pair: Megrez.KeyValuePaired) -> Bool {
|
||||
lmFiltered.unigramsFor(key: pair.joinedKey()).map(\.value).contains(pair.value)
|
||||
}
|
||||
|
||||
/// 插入臨時資料。
|
||||
|
|
|
@ -62,8 +62,7 @@ public extension LMMgr {
|
|||
}
|
||||
|
||||
public var isAlreadyFiltered: Bool {
|
||||
let results = LMMgr.getLM(mode: inputMode).queryFilteredValue(key: joinedKey) ?? []
|
||||
return results.contains(value)
|
||||
LMMgr.getLM(mode: inputMode).isPairFiltered(pair: .init(keyArray: keyArray, value: value))
|
||||
}
|
||||
|
||||
public func write(toFilter: Bool) -> Bool {
|
||||
|
|
Loading…
Reference in New Issue