fix: input kimi and then delete, you won't get any conversion result

This commit is contained in:
ensan-hcl
2025-07-15 14:52:35 -07:00
parent 48c267f47e
commit 031f3f466c
2 changed files with 33 additions and 13 deletions

View File

@@ -44,18 +44,16 @@ extension Kana2Kanji {
let latticeIndices = indexMap.indices(inputCount: inputCount, surfaceCount: surfaceCount)
var lattice = previousResult.lattice.prefix(inputCount: commonInputCount, surfaceCount: commonSurfaceCount)
let terminalNodes: Lattice
if counts.addedInput == 0 && counts.addedSurface == 0 {
terminalNodes = Lattice(
inputCount: inputCount,
surfaceCount: surfaceCount,
rawNodes: lattice.map {
$0.filter {
$0.range.endIndex == .input(inputCount) || $0.range.endIndex == .surface(inputCount)
}
var terminalNodes = Lattice(
inputCount: inputCount,
surfaceCount: surfaceCount,
rawNodes: lattice.map {
$0.filter {
$0.range.endIndex == .input(inputCount) || $0.range.endIndex == .surface(surfaceCount)
}
)
} else {
}
)
if !(counts.addedInput == 0 && counts.addedSurface == 0) {
// (2)
let rawNodes = latticeIndices.map { index in
let inputRange: (startIndex: Int, endIndexRange: Range<Int>?)? = if let iIndex = index.inputIndex, max(commonInputCount, iIndex) < inputCount {
@@ -80,7 +78,6 @@ extension Kana2Kanji {
surfaceCount: surfaceCount,
rawNodes: rawNodes
)
// (3)
for nodeArray in lattice {
for node in nodeArray {
@@ -98,7 +95,7 @@ extension Kana2Kanji {
}
}
lattice.merge(addedNodes)
terminalNodes = addedNodes
terminalNodes.merge(addedNodes)
}
// (3)