aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/android/inputmethod/latin/Suggest.java
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2009-07-30 10:11:33 -0700
committerJean-Baptiste Queru <jbq@google.com>2009-08-13 17:29:34 -0700
commit63fa90a7910d9f43f27a0bf9a6702f8fb44ce3e7 (patch)
treec12d4cfe9b3b67282755db9fbaceb124f70a94fb /src/com/android/inputmethod/latin/Suggest.java
parente5c7f0981d869806bc2ea7d58379a3138e0a0186 (diff)
downloadlatinime-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/Suggest.java')
-rwxr-xr-xsrc/com/android/inputmethod/latin/Suggest.java28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/com/android/inputmethod/latin/Suggest.java b/src/com/android/inputmethod/latin/Suggest.java
index 077d76aba..bb6a153dc 100755
--- a/src/com/android/inputmethod/latin/Suggest.java
+++ b/src/com/android/inputmethod/latin/Suggest.java
@@ -113,24 +113,34 @@ public class Suggest implements Dictionary.WordCallback {
mStringPool.add(sb);
}
}
-
+
private boolean haveSufficientCommonality(String original, CharSequence suggestion) {
- final int len = Math.min(original.length(), suggestion.length());
- if (len <= 2) return true;
+ final int originalLength = original.length();
+ final int suggestionLength = suggestion.length();
+ final int minLength = Math.min(originalLength, suggestionLength);
+ if (minLength <= 2) return true;
int matching = 0;
- for (int i = 0; i < len; i++) {
- if (ExpandableDictionary.toLowerCase(original.charAt(i))
- == ExpandableDictionary.toLowerCase(suggestion.charAt(i))) {
+ int lessMatching = 0; // Count matches if we skip one character
+ int i;
+ for (i = 0; i < minLength; i++) {
+ final char origChar = ExpandableDictionary.toLowerCase(original.charAt(i));
+ if (origChar == ExpandableDictionary.toLowerCase(suggestion.charAt(i))) {
matching++;
+ lessMatching++;
+ } else if (i + 1 < suggestionLength
+ && origChar == ExpandableDictionary.toLowerCase(suggestion.charAt(i + 1))) {
+ lessMatching++;
}
}
- if (len <= 4) {
+ matching = Math.max(matching, lessMatching);
+
+ if (minLength <= 4) {
return matching >= 2;
} else {
- return matching > len / 2;
+ return matching > minLength / 2;
}
}
-
+
/**
* Returns a list of words that match the list of character codes passed in.
* This list will be overwritten the next time this function is called.