From 461f94fec45bbd6eb7ca37d1dcd52e444eb49783 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Tue, 17 May 2022 16:00:45 +0800 Subject: [PATCH] KeyHandler_Core // Use walk() in lieu of reverseWalk(). --- .../ControllerModules/KeyHandler_Core.swift | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Source/Modules/ControllerModules/KeyHandler_Core.swift b/Source/Modules/ControllerModules/KeyHandler_Core.swift index 329d8301..7c7b0ff6 100644 --- a/Source/Modules/ControllerModules/KeyHandler_Core.swift +++ b/Source/Modules/ControllerModules/KeyHandler_Core.swift @@ -117,15 +117,11 @@ class KeyHandler: NSObject { func walk() { // Retrieve the most likely grid, i.e. a Maximum Likelihood Estimation // of the best possible Mandarin characters given the input syllables, - // using the Viterbi algorithm implemented in the Megrez library - let walker = Megrez.Walker(grid: _builder.grid()) - - // the reverse walk traces the grid from the end - let walked = walker.reverseWalk(at: _builder.grid().width(), nodesLimit: 3, balanced: true) - - // then we use ".reversed()" to reverse the nodes so that we get the forward-walked nodes - _walkedNodes.removeAll() - _walkedNodes.append(contentsOf: walked.reversed()) + // using the Viterbi algorithm implemented in the Megrez library. + // The walk() traces the grid to the end, hence no need to use .reversed() here. + _walkedNodes = Megrez.Walker( + grid: _builder.grid() + ).walk(at: _builder.grid().width(), nodesLimit: 3, balanced: true) } func popOverflowComposingTextAndWalk() -> String { @@ -365,5 +361,4 @@ class KeyHandler: NSObject { } _composer.clear() } - }