diff options
author | 2011-01-26 21:15:53 -0800 | |
---|---|---|
committer | 2011-01-26 21:15:53 -0800 | |
commit | 2580492aa05a1fe22e59e7d6ba3296b19e4ae4e7 (patch) | |
tree | 1230bc83b015e01db33ec00c08f51028a7492786 /java/src | |
parent | d4a0e7461090e9f5e9f3f9427d9b7820cea2ff7c (diff) | |
parent | b5d7857fbc28d311d93de10d9e99f26045a518f0 (diff) | |
download | latinime-2580492aa05a1fe22e59e7d6ba3296b19e4ae4e7.tar.gz latinime-2580492aa05a1fe22e59e7d6ba3296b19e4ae4e7.tar.xz latinime-2580492aa05a1fe22e59e7d6ba3296b19e4ae4e7.zip |
am b5d7857f: Merge "Fix auto-correction threshold and promote full matched words" into honeycomb
* commit 'b5d7857fbc28d311d93de10d9e99f26045a518f0':
Fix auto-correction threshold and promote full matched words
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/Suggest.java | 2 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/Utils.java | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 04c63be51..ced355bb2 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -294,7 +294,7 @@ public class Suggest implements Dictionary.WordCallback { typedWord, mSuggestions.get(0), mPriorities[0]); if (LatinImeLogger.sDBG) { Log.d(TAG, "Normalized " + typedWord + "," + mSuggestions.get(0) + "," - + mPriorities[0] + normalizedScore + + mPriorities[0] + ", " + normalizedScore + "(" + mAutoCorrectionThreshold + ")"); } if (normalizedScore >= mAutoCorrectionThreshold) { diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java index bb7239daf..e6ec48cd2 100644 --- a/java/src/com/android/inputmethod/latin/Utils.java +++ b/java/src/com/android/inputmethod/latin/Utils.java @@ -275,9 +275,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, |