UOM // Fix a serious bug in Observation.Update().
This commit is contained in:
parent
282144be88
commit
067ceebf71
|
@ -34,6 +34,10 @@ extension vChewing {
|
||||||
class Override {
|
class Override {
|
||||||
var count: Int = 0
|
var count: Int = 0
|
||||||
var timestamp: Double = 0.0
|
var timestamp: Double = 0.0
|
||||||
|
init(count: Int = 0, timestamp: Double = 0) {
|
||||||
|
self.count = count
|
||||||
|
self.timestamp = timestamp
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Observation {
|
class Observation {
|
||||||
|
@ -42,10 +46,11 @@ extension vChewing {
|
||||||
|
|
||||||
func update(candidate: String, timestamp: Double) {
|
func update(candidate: String, timestamp: Double) {
|
||||||
count += 1
|
count += 1
|
||||||
if let neta = overrides[candidate] {
|
if overrides.keys.contains(candidate) {
|
||||||
neta.timestamp = timestamp
|
overrides[candidate]?.timestamp = timestamp
|
||||||
neta.count += 1
|
overrides[candidate]?.count += 1
|
||||||
overrides[candidate] = neta
|
} else {
|
||||||
|
overrides[candidate] = .init(count: 1, timestamp: timestamp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue