Files
AzooKeyKanaKanjiConverter/Sources/KanaKanjiConverterModule/ConversionAlgorithms/Core/UnchangedInputProcessing.swift

52 lines
1.7 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// no_change.swift
// Keyboard
//
// Created by ensan on 2022/11/09.
// Copyright © 2022 ensan. All rights reserved.
//
import Algorithms
import Foundation
import SwiftUtils
extension Kana2Kanji {
/// ,
/// - Parameters:
/// - N_best: N_best
/// - previousResult:
/// - Returns:
///
///
/// ###
/// (1)resultregister
/// N_best
///
/// (2)
func kana2lattice_no_change(N_best: Int, previousResult: (inputData: ComposingText, lattice: Lattice)) -> (result: LatticeNode, lattice: Lattice) {
debug("キャッシュから復元、元の文字は:", previousResult.inputData.convertTarget)
let inputCount = previousResult.inputData.input.count
let surfaceCount = previousResult.inputData.convertTarget.count
// (1)
let result = LatticeNode.EOSNode
for nodeArray in previousResult.lattice {
for node in nodeArray where node.range.endIndex == .input(inputCount) || node.range.endIndex == .surface(surfaceCount) {
if node.prevs.isEmpty {
continue
}
if self.dicdataStore.shouldBeRemoved(data: node.data) {
continue
}
self.updateResultNode(with: node, resultNode: result)
}
}
// (2)
return (result: result, lattice: previousResult.lattice)
}
}