aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod
diff options
context:
space:
mode:
authorsatok <satok@google.com>2011-04-26 23:55:13 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-04-26 23:55:13 -0700
commitbc475dc297ab657cf8c859547a581e6c8e166cf3 (patch)
tree2421eda884f19c5b9c0d28783252df73a9f76878 /java/src/com/android/inputmethod
parentb880ccc3bd9e74524f4d27c6768e757718ff2c21 (diff)
parentb2e5e5937ca96a448081466a9f43e937787f0c24 (diff)
downloadlatinime-bc475dc297ab657cf8c859547a581e6c8e166cf3.tar.gz
latinime-bc475dc297ab657cf8c859547a581e6c8e166cf3.tar.xz
latinime-bc475dc297ab657cf8c859547a581e6c8e166cf3.zip
Merge "Handle overflow properly in multiplyRate"
Diffstat (limited to 'java/src/com/android/inputmethod')
-rw-r--r--java/src/com/android/inputmethod/latin/Utils.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java
index b5afb5079..9ce305f32 100644
--- a/java/src/com/android/inputmethod/latin/Utils.java
+++ b/java/src/com/android/inputmethod/latin/Utils.java
@@ -48,6 +48,7 @@ public class Utils {
private static final String TAG = Utils.class.getSimpleName();
private static final int MINIMUM_SAFETY_NET_CHAR_LENGTH = 4;
private static boolean DBG = LatinImeLogger.sDBG;
+ private static boolean DBG_EDIT_DISTANCE = false;
private Utils() {
// Intentional empty constructor for utility class.
@@ -289,7 +290,7 @@ public class Utils {
}
}
}
- if (LatinImeLogger.sDBG) {
+ if (DBG_EDIT_DISTANCE) {
Log.d(TAG, "editDistance:" + s + "," + t);
for (int i = 0; i < dp.length; ++i) {
StringBuffer sb = new StringBuffer();
@@ -338,6 +339,7 @@ public class Utils {
private static final int MAX_INITIAL_SCORE = 255;
private static final int TYPED_LETTER_MULTIPLIER = 2;
private static final int FULL_WORD_MULTIPLIER = 2;
+ private static final int S_INT_MAX = 2147483647;
public static double calcNormalizedScore(CharSequence before, CharSequence after, int score) {
final int beforeLength = before.length();
final int afterLength = after.length();
@@ -352,7 +354,7 @@ public class Utils {
}
}
if (spaceCount == afterLength) return 0;
- final double maximumScore = MAX_INITIAL_SCORE
+ final double maximumScore = score == S_INT_MAX ? S_INT_MAX : MAX_INITIAL_SCORE
* Math.pow(
TYPED_LETTER_MULTIPLIER, Math.min(beforeLength, afterLength - spaceCount))
* FULL_WORD_MULTIPLIER;