aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorsatok <satok@google.com>2011-04-20 02:13:28 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-04-20 02:13:28 -0700
commit5454ff5a66e681a034ceae6ffc9847ed9eb959d3 (patch)
tree0f42a359773acf1cb3c47b1860b5012add590745 /java/src
parentc9bc5c8d341666524a15e3c9aef3a50d1e294223 (diff)
parent22104663fc3ed9228c6a6ac35a893b23e50c8b33 (diff)
downloadlatinime-5454ff5a66e681a034ceae6ffc9847ed9eb959d3.tar.gz
latinime-5454ff5a66e681a034ceae6ffc9847ed9eb959d3.tar.xz
latinime-5454ff5a66e681a034ceae6ffc9847ed9eb959d3.zip
Merge "Tweak the normalized score for the words with spaces"
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/Utils.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java
index f01a81d6e..f8b23cb65 100644
--- a/java/src/com/android/inputmethod/latin/Utils.java
+++ b/java/src/com/android/inputmethod/latin/Utils.java
@@ -19,6 +19,7 @@ package com.android.inputmethod.latin;
import com.android.inputmethod.compat.InputMethodInfoCompatWrapper;
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.compat.InputTypeCompatUtils;
+import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardId;
import android.content.Context;
@@ -344,8 +345,16 @@ public class Utils {
final int distance = editDistance(before, after);
// If afterLength < beforeLength, the algorithm is suggesting a word by excessive character
// correction.
+ int spaceCount = 0;
+ for (int i = 0; i < afterLength; ++i) {
+ if (after.charAt(i) == Keyboard.CODE_SPACE) {
+ ++spaceCount;
+ }
+ }
+ if (spaceCount == afterLength) return 0;
final double maximumScore = MAX_INITIAL_SCORE
- * Math.pow(TYPED_LETTER_MULTIPLIER, Math.min(beforeLength, afterLength))
+ * Math.pow(
+ TYPED_LETTER_MULTIPLIER, Math.min(beforeLength, afterLength - spaceCount))
* FULL_WORD_MULTIPLIER;
// add a weight based on edit distance.
// distance <= max(afterLength, beforeLength) == afterLength,