aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/Utils.java
diff options
context:
space:
mode:
authorsatok <satok@google.com>2011-10-12 23:44:54 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-10-12 23:44:54 -0700
commit605a6fea750c4acc96a5136ecaf7162e0a858b9f (patch)
treece110e0665dda3f5a32998361b498f6b00b2380d /java/src/com/android/inputmethod/latin/Utils.java
parent8a4472f0ecd774757c7077a40585f2d05e4f9210 (diff)
parent2aa1dd45c44295e2f7e8ece1b520032d86b9f908 (diff)
downloadlatinime-605a6fea750c4acc96a5136ecaf7162e0a858b9f.tar.gz
latinime-605a6fea750c4acc96a5136ecaf7162e0a858b9f.tar.xz
latinime-605a6fea750c4acc96a5136ecaf7162e0a858b9f.zip
Merge "Fix the safety net Bug: 5453150" into ics-mr0
Diffstat (limited to 'java/src/com/android/inputmethod/latin/Utils.java')
-rw-r--r--java/src/com/android/inputmethod/latin/Utils.java14
1 files changed, 9 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java
index de2930460..f6343f1d7 100644
--- a/java/src/com/android/inputmethod/latin/Utils.java
+++ b/java/src/com/android/inputmethod/latin/Utils.java
@@ -167,7 +167,9 @@ public class Utils {
throw new RuntimeException("Can not find input method id for " + packageName);
}
- public static boolean shouldBlockedBySafetyNetForAutoCorrection(SuggestedWords suggestions,
+ // TODO: Resolve the inconsistencies between the native auto correction algorithms and
+ // this safety net
+ public static boolean shouldBlockAutoCorrectionBySafetyNet(SuggestedWords suggestions,
Suggest suggest) {
// Safety net for auto correction.
// Actually if we hit this safety net, it's actually a bug.
@@ -181,7 +183,8 @@ public class Utils {
if (typedWord.length() < MINIMUM_SAFETY_NET_CHAR_LENGTH) return false;
final CharSequence suggestionWord = suggestions.getWord(1);
final int typedWordLength = typedWord.length();
- final int maxEditDistanceOfNativeDictionary = typedWordLength < 5 ? 2 : typedWordLength / 2;
+ final int maxEditDistanceOfNativeDictionary =
+ (typedWordLength < 5 ? 2 : typedWordLength / 2) + 1;
final int distance = Utils.editDistance(typedWord, suggestionWord);
if (DBG) {
Log.d(TAG, "Autocorrected edit distance = " + distance
@@ -189,8 +192,8 @@ public class Utils {
}
if (distance > maxEditDistanceOfNativeDictionary) {
if (DBG) {
- Log.d(TAG, "Safety net: before = " + typedWord + ", after = " + suggestionWord);
- Log.w(TAG, "(Error) The edit distance of this correction exceeds limit. "
+ Log.e(TAG, "Safety net: before = " + typedWord + ", after = " + suggestionWord);
+ Log.e(TAG, "(Error) The edit distance of this correction exceeds limit. "
+ "Turning off auto-correction.");
}
return true;
@@ -792,6 +795,7 @@ public class Utils {
}
public static boolean willAutoCorrect(SuggestedWords suggestions) {
- return !suggestions.mTypedWordValid && suggestions.mHasMinimalSuggestion;
+ return !suggestions.mTypedWordValid && suggestions.mHasAutoCorrectionCandidate
+ && !suggestions.shouldBlockAutoCorrection();
}
}