Megrez // Add a safe check in Compositor.update().

This commit is contained in:
ShikiSuen 2023-12-01 12:05:48 +08:00
parent 2880901491
commit 2f81bd5824
1 changed files with 1 additions and 1 deletions

View File

@ -294,7 +294,7 @@ extension Megrez.Compositor {
guard position + theLength <= keys.count, position >= 0 else { return } guard position + theLength <= keys.count, position >= 0 else { return }
let joinedKeyArray = keys[position ..< (position + theLength)].map(\.description) let joinedKeyArray = keys[position ..< (position + theLength)].map(\.description)
if let theNode = spans[position][theLength] { if (0 ..< spans.count).contains(position), let theNode = spans[position][theLength] {
if !updateExisting { return } if !updateExisting { return }
let unigrams = langModel.unigramsFor(keyArray: joinedKeyArray) let unigrams = langModel.unigramsFor(keyArray: joinedKeyArray)
// //