Megrez // Fix Unigram.consolidate(), letting it handle nerfed scores.

This commit is contained in:
ShikiSuen 2022-10-02 13:36:13 +08:00
parent c3d3d95a1f
commit af6c11beab
1 changed files with 1 additions and 2 deletions

View File

@ -43,12 +43,11 @@ extension Megrez {
extension Array where Element == Megrez.Unigram { extension Array where Element == Megrez.Unigram {
/// ///
///
public mutating func consolidate(filter theFilter: Set<String> = .init()) { public mutating func consolidate(filter theFilter: Set<String> = .init()) {
var inserted: [String: Double] = [:] var inserted: [String: Double] = [:]
var insertedArray: [Megrez.Unigram] = [] var insertedArray: [Megrez.Unigram] = []
for neta in filter({ !theFilter.contains($0.value) }) { for neta in filter({ !theFilter.contains($0.value) }) {
if let existed = inserted[neta.value], existed >= neta.score { continue } if inserted.keys.contains(neta.value) { continue }
inserted[neta.value] = neta.score inserted[neta.value] = neta.score
insertedArray.append(neta) insertedArray.append(neta)
} }