diff options
author | 2010-02-05 14:07:04 -0800 | |
---|---|---|
committer | 2010-02-08 15:22:37 -0800 | |
commit | 1b62ff1a3d61cd44ab88acdfcbdf0fc70a7e1b10 (patch) | |
tree | 17739a10acf4f7f9e70b82ba4d0a2f1c17c914b4 /src/com/android/inputmethod/latin/ExpandableDictionary.java | |
parent | 8fa317a61a2152347c59dda7eb1b8e2979f6cc1d (diff) | |
download | latinime-1b62ff1a3d61cd44ab88acdfcbdf0fc70a7e1b10.tar.gz latinime-1b62ff1a3d61cd44ab88acdfcbdf0fc70a7e1b10.tar.xz latinime-1b62ff1a3d61cd44ab88acdfcbdf0fc70a7e1b10.zip |
Increase target size of preferred letters while typing.
This increases the chance of hitting the correct letter when typing a word
that exists in the dictionary, rather than only correct it after the fact.
It is most effective after 2 or 3 letters of a word have been typed and gets
more accurate with more typed letters in the word.
If 2 adjacent letters have similar probabilities of occuring, then there is no
hit correction applied.
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, |