aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeisuke Kuroyanagi <ksk@google.com>2013-12-18 14:31:10 +0900
committerKeisuke Kuroyanagi <ksk@google.com>2013-12-18 14:31:10 +0900
commitd5f5dd74c2e0946d4686a4f22cda1591b34b6729 (patch)
treee3e46cb0ddeb1c6a5f6074c9fd645d04535145e3
parent5edae8cea0a432917eb474905e170b572b450bc5 (diff)
downloadlatinime-d5f5dd74c2e0946d4686a4f22cda1591b34b6729.tar.gz
latinime-d5f5dd74c2e0946d4686a4f22cda1591b34b6729.tar.xz
latinime-d5f5dd74c2e0946d4686a4f22cda1591b34b6729.zip
Quit suggest words that do not include proximity chars.
Bug: 10416722 Change-Id: I74d27c6a22b4ca47d02eb238b2fbcc49f5dee99c
-rw-r--r--native/jni/src/suggest/core/dicnode/dic_node.h7
-rw-r--r--native/jni/src/suggest/core/suggest.cpp3
2 files changed, 10 insertions, 0 deletions
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);