KeyHandler // Add fixNodeIfNecessary().
This commit is contained in:
parent
ba4654f850
commit
48d21fd60e
|
@ -108,6 +108,27 @@ class KeyHandler {
|
|||
|
||||
// MARK: - Functions dealing with Megrez.
|
||||
|
||||
func fixNodeIfNecessary() {
|
||||
let width = _builder.grid.width
|
||||
if width > kMaxComposingBufferNeedsToWalkSize {
|
||||
var index = 0
|
||||
for anchor in _walkedNodes {
|
||||
if index >= (width - kMaxComposingBufferNeedsToWalkSize) {
|
||||
break
|
||||
}
|
||||
guard let node = anchor.node else { continue }
|
||||
if node.score < node.kSelectedCandidateScore {
|
||||
let candidate = node.currentKeyValue.value
|
||||
_builder.grid.fixNodeSelectedCandidate(
|
||||
location: index + anchor.spanningLength,
|
||||
value: candidate
|
||||
)
|
||||
}
|
||||
index += anchor.spanningLength
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func walk() {
|
||||
// Retrieve the most likely grid, i.e. a Maximum Likelihood Estimation
|
||||
// of the best possible Mandarin characters given the input syllables,
|
||||
|
|
|
@ -190,6 +190,9 @@ extension KeyHandler {
|
|||
// ... get and tweak override model suggestion if possible...
|
||||
dealWithOverrideModelSuggestions()
|
||||
|
||||
// ... and fix nodes if necessary...
|
||||
fixNodeIfNecessary()
|
||||
|
||||
// ... then update the text.
|
||||
_composer.clear()
|
||||
|
||||
|
|
Loading…
Reference in New Issue