UOM // Remove decayCallback().

This commit is contained in:
ShikiSuen 2022-08-12 15:29:27 +08:00
parent ab685149e7
commit 15308a1148
1 changed files with 8 additions and 20 deletions

View File

@ -278,26 +278,19 @@ extension vChewing.LMUserOverride {
saveCallback()
return
}
// TODO:
// decayCallback
if var theNeta = mutLRUMap[key] {
_ = getSuggestion(
key: key, timestamp: timestamp, headReading: "",
decayCallback: {
theNeta.observation.update(
candidate: candidate, timestamp: timestamp, forceHighScoreOverride: forceHighScoreOverride
)
self.mutLRUList.insert(theNeta, at: 0)
self.mutLRUMap[key] = theNeta
IME.prtDebugIntel("UOM: Observation finished with existing observation: \(key)")
saveCallback()
}
theNeta.observation.update(
candidate: candidate, timestamp: timestamp, forceHighScoreOverride: forceHighScoreOverride
)
mutLRUList.insert(theNeta, at: 0)
mutLRUMap[key] = theNeta
IME.prtDebugIntel("UOM: Observation finished with existing observation: \(key)")
saveCallback()
}
}
private func getSuggestion(
key: String, timestamp: Double, headReading: String, decayCallback: @escaping () -> Void = {}
) -> Suggestion {
private func getSuggestion(key: String, timestamp: Double, headReading: String) -> Suggestion {
guard !key.isEmpty, let kvPair = mutLRUMap[key] else { return .init() }
let observation: Observation = kvPair.observation
var candidates: [(String, Megrez.Unigram)] = .init()
@ -309,11 +302,6 @@ extension vChewing.LMUserOverride {
eventTimestamp: theObservation.timestamp, timestamp: timestamp, lambda: mutDecayExponent
)
if (0...currentHighScore).contains(overrideScore) { continue }
let overrideDetectionScore: Double = getScore(
eventCount: theObservation.count, totalCount: observation.count,
eventTimestamp: theObservation.timestamp, timestamp: timestamp, lambda: mutDecayExponent * 2
)
if (0...currentHighScore).contains(overrideDetectionScore) { decayCallback() }
candidates.append((headReading, .init(value: i, score: overrideScore)))
forceHighScoreOverride = theObservation.forceHighScoreOverride