diff options
author | 2012-02-15 20:00:54 -0800 | |
---|---|---|
committer | 2012-02-15 20:00:54 -0800 | |
commit | 25ff89a75cb8b797bdaf0c7b78e50fd454c1b1e2 (patch) | |
tree | d19bbd65efba508b6f7c4bbd18354c5124891a9a | |
parent | a252e0547f82e8c6778619465364328accab6353 (diff) | |
parent | ad290d6505247171e1e8437446c6f5d148a01778 (diff) | |
download | latinime-25ff89a75cb8b797bdaf0c7b78e50fd454c1b1e2.tar.gz latinime-25ff89a75cb8b797bdaf0c7b78e50fd454c1b1e2.tar.xz latinime-25ff89a75cb8b797bdaf0c7b78e50fd454c1b1e2.zip |
Merge "Activate bigram predictions from the binary dictionary"
-rw-r--r-- | java/src/com/android/inputmethod/latin/BinaryDictionary.java | 15 | ||||
-rw-r--r-- | native/src/bigram_dictionary.cpp | 3 |
2 files changed, 8 insertions, 10 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index b82400046..90ced6028 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -139,22 +139,19 @@ public class BinaryDictionary extends Dictionary { Arrays.fill(mBigramScores, 0); int codesSize = codes.size(); - if (codesSize <= 0) { - // Do not return bigrams from BinaryDictionary when nothing was typed. - // Only use user-history bigrams (or whatever other bigram dictionaries decide). - return; - } Arrays.fill(mInputCodes, -1); - int[] alternatives = codes.getCodesAt(0); - System.arraycopy(alternatives, 0, mInputCodes, 0, - Math.min(alternatives.length, MAX_PROXIMITY_CHARS_SIZE)); + if (codesSize > 0) { + int[] alternatives = codes.getCodesAt(0); + System.arraycopy(alternatives, 0, mInputCodes, 0, + Math.min(alternatives.length, MAX_PROXIMITY_CHARS_SIZE)); + } int count = getBigramsNative(mNativeDict, chars, chars.length, mInputCodes, codesSize, mOutputChars_bigrams, mBigramScores, MAX_WORD_LENGTH, MAX_BIGRAMS, MAX_PROXIMITY_CHARS_SIZE); for (int j = 0; j < count; ++j) { - if (mBigramScores[j] < 1) break; + if (codesSize > 0 && mBigramScores[j] < 1) break; final int start = j * MAX_WORD_LENGTH; int len = 0; while (len < MAX_WORD_LENGTH && mOutputChars_bigrams[start + len] != 0) { diff --git a/native/src/bigram_dictionary.cpp b/native/src/bigram_dictionary.cpp index db7734bc7..19b644679 100644 --- a/native/src/bigram_dictionary.cpp +++ b/native/src/bigram_dictionary.cpp @@ -134,7 +134,8 @@ int BigramDictionary::getBigrams(unsigned short *prevWord, int prevWordLength, i const int length = BinaryFormat::getWordAtAddress(root, bigramPos, MAX_WORD_LENGTH, bigramBuffer); - if (checkFirstCharacter(bigramBuffer)) { + // codesSize == 0 means we are trying to find bigram predictions. + if (codesSize < 1 || checkFirstCharacter(bigramBuffer)) { const int frequency = UnigramDictionary::MASK_ATTRIBUTE_FREQUENCY & bigramFlags; addWordBigram(bigramBuffer, length, frequency); } |