From d5f5dd74c2e0946d4686a4f22cda1591b34b6729 Mon Sep 17 00:00:00 2001 From: Keisuke Kuroyanagi Date: Wed, 18 Dec 2013 14:31:10 +0900 Subject: [PATCH] Quit suggest words that do not include proximity chars. Bug: 10416722 Change-Id: I74d27c6a22b4ca47d02eb238b2fbcc49f5dee99c --- native/jni/src/suggest/core/dicnode/dic_node.h | 7 +++++++ native/jni/src/suggest/core/suggest.cpp | 3 +++ 2 files changed, 10 insertions(+) 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);