From 82ddd168893892cfe4366e1e2fa9e9bfeb5478a5 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Mon, 16 Jan 2012 18:48:19 +0900 Subject: [PATCH] Stop avoiding adding what the user typed to candidates There does not seem to be any reason other than a historical one to avoid doing this, but it takes processing power and makes things more complicated. This has a very limited impact on regression tests: 5 -> 3 [He, the] 5 -> 3 [An, an] 5 -> 3 [Where, where] 5 -> 3 [This, this] 7 -> 1 [wAtch, watch] 6 -> 4 [oveNs, oceans] 5 -> 1 [Ahere, Where] 7 -> 1 [Hast, Hast] 7 -> 5 [bjp, bill] 5 -> 1 [What, What] 5 -> 3 [Sound, So und] 7 -> 3 [causalities, casualties] 7 -> 3 [discontentment, discontent] 7 -> 3 [irregardless, regardless] 5 -> 1 : 2 5 -> 3 : 5 6 -> 4 : 1 7 -> 1 : 2 7 -> 3 : 3 7 -> 5 : 1 +1 4 -1 0 +2 0 -2 0 +3 8 -3 0 +4 1 -4 0 +5 1 -5 7 +6 0 -6 1 +7 0 -7 6 Change-Id: I6407cf922f27bbd3992df11d63690e71fc61111b --- native/src/correction.cpp | 4 ++-- native/src/defines.h | 1 + native/src/unigram_dictionary.cpp | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/native/src/correction.cpp b/native/src/correction.cpp index 43ab3f59c..75831b69d 100644 --- a/native/src/correction.cpp +++ b/native/src/correction.cpp @@ -168,8 +168,8 @@ int Correction::getFinalFreq(const int freq, unsigned short **word, int *wordLen const int outputIndex = mTerminalOutputIndex; const int inputIndex = mTerminalInputIndex; *wordLength = outputIndex + 1; - if (mProximityInfo->sameAsTyped(mWord, outputIndex + 1) || outputIndex < MIN_SUGGEST_DEPTH) { - return -1; + if (outputIndex < MIN_SUGGEST_DEPTH) { + return NOT_A_FREQUENCY; } *word = mWord; diff --git a/native/src/defines.h b/native/src/defines.h index 48f92d86c..ce3f85acd 100644 --- a/native/src/defines.h +++ b/native/src/defines.h @@ -172,6 +172,7 @@ static void prof_out(void) { #define EQUIVALENT_CHAR_WITHOUT_DISTANCE_INFO -2 #define PROXIMITY_CHAR_WITHOUT_DISTANCE_INFO -3 #define NOT_A_INDEX -1 +#define NOT_A_FREQUENCY -1 #define KEYCODE_SPACE ' ' diff --git a/native/src/unigram_dictionary.cpp b/native/src/unigram_dictionary.cpp index 85e7e9bf2..69e3200fc 100644 --- a/native/src/unigram_dictionary.cpp +++ b/native/src/unigram_dictionary.cpp @@ -335,7 +335,7 @@ inline void UnigramDictionary::onTerminal(const int freq, int wordLength; unsigned short* wordPointer; const int finalFreq = correction->getFinalFreq(freq, &wordPointer, &wordLength); - if (finalFreq >= 0) { + if (finalFreq != NOT_A_FREQUENCY) { if (!terminalAttributes.isShortcutOnly()) { if (addToMasterQueue) { addWord(wordPointer, wordLength, finalFreq, masterQueue);