diff options
Diffstat (limited to 'src/com/android/inputmethod/latin/ExpandableDictionary.java')
-rw-r--r-- | src/com/android/inputmethod/latin/ExpandableDictionary.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/com/android/inputmethod/latin/ExpandableDictionary.java b/src/com/android/inputmethod/latin/ExpandableDictionary.java index 1589168ee..648f577ca 100644 --- a/src/com/android/inputmethod/latin/ExpandableDictionary.java +++ b/src/com/android/inputmethod/latin/ExpandableDictionary.java @@ -27,6 +27,7 @@ public class ExpandableDictionary extends Dictionary { private char[] mWordBuilder = new char[MAX_WORD_LENGTH]; private int mMaxDepth; private int mInputLength; + private int[] mNextLettersFrequencies; public static final int MAX_WORD_LENGTH = 32; private static final char QUOTE = '\''; @@ -116,8 +117,10 @@ public class ExpandableDictionary extends Dictionary { } @Override - public void getWords(final WordComposer codes, final WordCallback callback) { + public void getWords(final WordComposer codes, final WordCallback callback, + int[] nextLettersFrequencies) { mInputLength = codes.size(); + mNextLettersFrequencies = nextLettersFrequencies; if (mCodes.length < mInputLength) mCodes = new int[mInputLength][]; // Cache the codes so that we don't have to lookup an array list for (int i = 0; i < mInputLength; i++) { @@ -216,6 +219,11 @@ public class ExpandableDictionary extends Dictionary { if (!callback.addWord(word, 0, depth + 1, freq * snr)) { return; } + // Add to frequency of next letters for predictive correction + if (mNextLettersFrequencies != null && depth >= inputIndex && skipPos < 0 + && mNextLettersFrequencies.length > word[inputIndex]) { + mNextLettersFrequencies[word[inputIndex]]++; + } } if (children != null) { getWordsRec(children, codes, word, depth + 1, completion, snr, inputIndex, |