diff options
author | 2009-07-30 10:11:33 -0700 | |
---|---|---|
committer | 2009-08-13 17:29:34 -0700 | |
commit | 63fa90a7910d9f43f27a0bf9a6702f8fb44ce3e7 (patch) | |
tree | c12d4cfe9b3b67282755db9fbaceb124f70a94fb /src/com/android/inputmethod/latin/ExpandableDictionary.java | |
parent | e5c7f0981d869806bc2ea7d58379a3138e0a0186 (diff) | |
download | latinime-63fa90a7910d9f43f27a0bf9a6702f8fb44ce3e7.tar.gz latinime-63fa90a7910d9f43f27a0bf9a6702f8fb44ce3e7.tar.xz latinime-63fa90a7910d9f43f27a0bf9a6702f8fb44ce3e7.zip |
Check for missing characters in User/Contacts dictionary as well.
Also accomodate for missing characters when doing diffs between words.
Diffstat (limited to 'src/com/android/inputmethod/latin/ExpandableDictionary.java')
-rw-r--r-- | src/com/android/inputmethod/latin/ExpandableDictionary.java | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/com/android/inputmethod/latin/ExpandableDictionary.java b/src/com/android/inputmethod/latin/ExpandableDictionary.java index 5235e8712..3f20783e4 100644 --- a/src/com/android/inputmethod/latin/ExpandableDictionary.java +++ b/src/com/android/inputmethod/latin/ExpandableDictionary.java @@ -102,7 +102,10 @@ public class ExpandableDictionary extends Dictionary { public void getWords(final WordComposer codes, final WordCallback callback) { mInputLength = codes.size(); mMaxDepth = mInputLength * 3; - getWordsRec(mRoots, codes, mWordBuilder, 0, false, 1.0f, 0, callback); + getWordsRec(mRoots, codes, mWordBuilder, 0, false, 1.0f, 0, -1, callback); + for (int i = 0; i < mInputLength; i++) { + getWordsRec(mRoots, codes, mWordBuilder, 0, false, 1.0f, 0, i, callback); + } } @Override @@ -163,7 +166,7 @@ public class ExpandableDictionary extends Dictionary { * @param callback the callback class for adding a word */ protected void getWordsRec(List<Node> roots, final WordComposer codes, final char[] word, - final int depth, boolean completion, float snr, int inputIndex, + final int depth, boolean completion, float snr, int inputIndex, int skipPos, WordCallback callback) { final int count = roots.size(); final int codeSize = mInputLength; @@ -193,18 +196,20 @@ public class ExpandableDictionary extends Dictionary { } } if (children != null) { - getWordsRec(children, codes, word, depth + 1, completion, snr, inputIndex, - callback); + getWordsRec(children, codes, word, depth + 1, completion, snr, inputIndex, + skipPos, callback); } - } else if (c == QUOTE && currentChars[0] != QUOTE) { + } else if ((c == QUOTE && currentChars[0] != QUOTE) || depth == skipPos) { // Skip the ' and continue deeper - word[depth] = QUOTE; + word[depth] = c; if (children != null) { getWordsRec(children, codes, word, depth + 1, completion, snr, inputIndex, - callback); + skipPos, callback); } } else { - for (int j = 0; j < currentChars.length; j++) { + // Don't use alternatives if we're looking for missing characters + final int alternativesSize = skipPos >= 0? 1 : currentChars.length; + for (int j = 0; j < alternativesSize; j++) { float addedAttenuation = (j > 0 ? 1f : 3f); if (currentChars[j] == -1) { break; @@ -223,11 +228,13 @@ public class ExpandableDictionary extends Dictionary { } if (children != null) { getWordsRec(children, codes, word, depth + 1, - true, snr * addedAttenuation, inputIndex + 1, callback); + true, snr * addedAttenuation, inputIndex + 1, + skipPos, callback); } } else if (children != null) { getWordsRec(children, codes, word, depth + 1, - false, snr * addedAttenuation, inputIndex + 1, callback); + false, snr * addedAttenuation, inputIndex + 1, + skipPos, callback); } } } |