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
|
return result.isEmpty ? nil : result
|
||||||
}
|
}
|
||||||
|
|
||||||
public func queryFilteredValue(key: String) -> [String]? {
|
public func isPairFiltered(pair: Megrez.KeyValuePaired) -> Bool {
|
||||||
let result = lmFiltered.unigramsFor(key: key).map(\.value)
|
lmFiltered.unigramsFor(key: pair.joinedKey()).map(\.value).contains(pair.value)
|
||||||
return result.isEmpty ? nil : result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 插入臨時資料。
|
/// 插入臨時資料。
|
||||||
|
|
|
@ -62,8 +62,7 @@ public extension LMMgr {
|
||||||
}
|
}
|
||||||
|
|
||||||
public var isAlreadyFiltered: Bool {
|
public var isAlreadyFiltered: Bool {
|
||||||
let results = LMMgr.getLM(mode: inputMode).queryFilteredValue(key: joinedKey) ?? []
|
LMMgr.getLM(mode: inputMode).isPairFiltered(pair: .init(keyArray: keyArray, value: value))
|
||||||
return results.contains(value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public func write(toFilter: Bool) -> Bool {
|
public func write(toFilter: Bool) -> Bool {
|
||||||
|
|
Loading…
Reference in New Issue