aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/Utils.java
diff options
context:
space:
mode:
authorsatok <satok@google.com>2011-10-12 23:46:25 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2011-10-12 23:46:25 -0700
commit22c2a23cdaa29c2de742d8ab3e8d7bf3c9f9564a (patch)
treeb0ac9a8ac09c4feadee73a91b2b6e50a4cfdc2cd /java/src/com/android/inputmethod/latin/Utils.java
parentca922b440ac2ba5b961e9b2df33187a9182bc174 (diff)
parent605a6fea750c4acc96a5136ecaf7162e0a858b9f (diff)
downloadlatinime-22c2a23cdaa29c2de742d8ab3e8d7bf3c9f9564a.tar.gz
latinime-22c2a23cdaa29c2de742d8ab3e8d7bf3c9f9564a.tar.xz
latinime-22c2a23cdaa29c2de742d8ab3e8d7bf3c9f9564a.zip
am 605a6fea: Merge "Fix the safety net Bug: 5453150" into ics-mr0
* commit '605a6fea750c4acc96a5136ecaf7162e0a858b9f': Fix the safety net Bug: 5453150
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 34c8c894b..b29ff1975 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;
@@ -808,6 +811,7 @@ public class Utils {
}
public static boolean willAutoCorrect(SuggestedWords suggestions) {
- return !suggestions.mTypedWordValid && suggestions.mHasMinimalSuggestion;
+ return !suggestions.mTypedWordValid && suggestions.mHasAutoCorrectionCandidate
+ && !suggestions.shouldBlockAutoCorrection();
}
}