LMUserOverride // Fix wrong process in observe().
This commit is contained in:
parent
8984784bdb
commit
788b9a60ee
|
@ -74,6 +74,9 @@ extension vChewing {
|
||||||
|
|
||||||
public init(capacity: Int = 500, decayConstant: Double = 5400.0) {
|
public init(capacity: Int = 500, decayConstant: Double = 5400.0) {
|
||||||
mutCapacity = abs(capacity) // Ensures that this value is always > 0.
|
mutCapacity = abs(capacity) // Ensures that this value is always > 0.
|
||||||
|
if mutCapacity == 0 {
|
||||||
|
mutCapacity = 1
|
||||||
|
}
|
||||||
mutDecayExponent = log(0.5) / decayConstant
|
mutDecayExponent = log(0.5) / decayConstant
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +91,7 @@ extension vChewing {
|
||||||
else {
|
else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
guard let map = mutLRUMap[key] else {
|
guard mutLRUMap[key] != nil else {
|
||||||
var observation: Observation = .init()
|
var observation: Observation = .init()
|
||||||
observation.update(candidate: candidate, timestamp: timestamp)
|
observation.update(candidate: candidate, timestamp: timestamp)
|
||||||
mutLRUMap[key] = KeyObservationPair(key: key, observation: observation)
|
mutLRUMap[key] = KeyObservationPair(key: key, observation: observation)
|
||||||
|
@ -100,10 +103,11 @@ extension vChewing {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var obs = map.observation
|
mutLRUList.insert(contentsOf: mutLRUMap.values, at: 0)
|
||||||
obs.update(candidate: candidate, timestamp: timestamp)
|
|
||||||
let pair = KeyObservationPair(key: key, observation: obs)
|
if mutLRUMap[key] != nil {
|
||||||
mutLRUList.insert(pair, at: 0)
|
mutLRUMap[key]?.observation.update(candidate: candidate, timestamp: timestamp)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func suggest(
|
public func suggest(
|
||||||
|
|
Loading…
Reference in New Issue