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/Suggest.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/Suggest.java')
-rwxr-xr-x | src/com/android/inputmethod/latin/Suggest.java | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/com/android/inputmethod/latin/Suggest.java b/src/com/android/inputmethod/latin/Suggest.java index c3fe99635..5833c02a5 100755 --- a/src/com/android/inputmethod/latin/Suggest.java +++ b/src/com/android/inputmethod/latin/Suggest.java @@ -52,6 +52,12 @@ public class Suggest implements Dictionary.WordCallback { private int mPrefMaxSuggestions = 12; private int[] mPriorities = new int[mPrefMaxSuggestions]; + // Handle predictive correction for only the first 1280 characters for performance reasons + // If we support scripts that need latin characters beyond that, we should probably use some + // kind of a sparse array or language specific list with a mapping lookup table. + // 1280 is the size of the BASE_CHARS array in ExpandableDictionary, which is a basic set of + // latin characters. + private int[] mNextLettersFrequencies = new int[1280]; private ArrayList<CharSequence> mSuggestions = new ArrayList<CharSequence>(); private ArrayList<CharSequence> mStringPool = new ArrayList<CharSequence>(); private boolean mHaveCorrection; @@ -162,7 +168,8 @@ public class Suggest implements Dictionary.WordCallback { mCapitalize = wordComposer.isCapitalized(); collectGarbage(); Arrays.fill(mPriorities, 0); - + Arrays.fill(mNextLettersFrequencies, 0); + // Save a lowercase version of the original word mOriginalWord = wordComposer.getTypedWord(); if (mOriginalWord != null) { @@ -175,17 +182,17 @@ public class Suggest implements Dictionary.WordCallback { if (wordComposer.size() > 1) { if (mUserDictionary != null || mContactsDictionary != null) { if (mUserDictionary != null) { - mUserDictionary.getWords(wordComposer, this); + mUserDictionary.getWords(wordComposer, this, mNextLettersFrequencies); } if (mContactsDictionary != null) { - mContactsDictionary.getWords(wordComposer, this); + mContactsDictionary.getWords(wordComposer, this, mNextLettersFrequencies); } if (mSuggestions.size() > 0 && isValidWord(mOriginalWord)) { mHaveCorrection = true; } } - mMainDict.getWords(wordComposer, this); + mMainDict.getWords(wordComposer, this, mNextLettersFrequencies); if (mCorrectionMode == CORRECTION_FULL && mSuggestions.size() > 0) { mHaveCorrection = true; } @@ -229,6 +236,10 @@ public class Suggest implements Dictionary.WordCallback { return mSuggestions; } + public int[] getNextLettersFrequencies() { + return mNextLettersFrequencies; + } + private void removeDupes() { final ArrayList<CharSequence> suggestions = mSuggestions; if (suggestions.size() < 2) return; |