diff --git a/native/jni/src/suggest/core/dicnode/dic_node.h b/native/jni/src/suggest/core/dicnode/dic_node.h index 0b2b4a9e8..069852d6e 100644 --- a/native/jni/src/suggest/core/dicnode/dic_node.h +++ b/native/jni/src/suggest/core/dicnode/dic_node.h @@ -280,6 +280,13 @@ class DicNode { return !(currentDepth > 0 && (currentDepth != 1 || prevWordLen != 1)); } + bool hasMatchedOrProximityCodePoints() const { + // This DicNode does not have matched or proximity code points when all code points have + // been handled as edit corrections so far. + return mDicNodeState.mDicNodeStateScoring.getEditCorrectionCount() + < getNodeCodePointCount(); + } + bool isTotalInputSizeExceedingLimit() const { const int prevWordsLen = mDicNodeState.mDicNodeStatePrevWord.getPrevWordLength(); const int currentWordDepth = getNodeCodePointCount(); diff --git a/native/jni/src/suggest/core/suggest.cpp b/native/jni/src/suggest/core/suggest.cpp index f84c84181..5377ec4e8 100644 --- a/native/jni/src/suggest/core/suggest.cpp +++ b/native/jni/src/suggest/core/suggest.cpp @@ -459,6 +459,9 @@ void Suggest::processTerminalDicNode( Weighting::addCostAndForwardInputIndex(WEIGHTING, CT_TERMINAL_INSERTION, traverseSession, 0, &terminalDicNode, traverseSession->getMultiBigramMap()); } + if (!dicNode->hasMatchedOrProximityCodePoints()) { + return; + } Weighting::addCostAndForwardInputIndex(WEIGHTING, CT_TERMINAL, traverseSession, 0, &terminalDicNode, traverseSession->getMultiBigramMap()); traverseSession->getDicTraverseCache()->copyPushTerminal(&terminalDicNode);