diff options
author | 2011-01-27 03:23:39 +0900 | |
---|---|---|
committer | 2011-01-27 12:53:13 +0900 | |
commit | 58c49b91322847dc453742cb34c2899da9b44479 (patch) | |
tree | 645f163d8a75a9e422946eb908c50c6efcecd8fa /java/src/com/android/inputmethod/latin/Utils.java | |
parent | 5c35e4109fc5a035605605b62bf5e5a5888b0f6b (diff) | |
download | latinime-58c49b91322847dc453742cb34c2899da9b44479.tar.gz latinime-58c49b91322847dc453742cb34c2899da9b44479.tar.xz latinime-58c49b91322847dc453742cb34c2899da9b44479.zip |
Fix auto-correction threshold and promote full matched words
Bug: 3374359
Bug: 3278422
"zbe" will be auto corrected to "be" by fixing s-line
"teh" will be auto corrected to "the" by promotion of full matched words
Change-Id: I314c632820e4e0b1501edeca60ada205d291451f
Diffstat (limited to 'java/src/com/android/inputmethod/latin/Utils.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/Utils.java | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java index 5059860d7..53009e4a6 100644 --- a/java/src/com/android/inputmethod/latin/Utils.java +++ b/java/src/com/android/inputmethod/latin/Utils.java @@ -267,9 +267,12 @@ public class Utils { public static double calcNormalizedScore(CharSequence before, CharSequence after, int score) { final int beforeLength = before.length(); final int afterLength = after.length(); + if (beforeLength == 0 || afterLength == 0) return 0; final int distance = editDistance(before, after); + // If afterLength < beforeLength, the algorithm is suggesting a word by excessive character + // correction. final double maximumScore = MAX_INITIAL_SCORE - * Math.pow(TYPED_LETTER_MULTIPLIER, beforeLength) + * Math.pow(TYPED_LETTER_MULTIPLIER, Math.min(beforeLength, afterLength)) * FULL_WORD_MULTIPLYER; // add a weight based on edit distance. // distance <= max(afterLength, beforeLength) == afterLength, |