diff options
author | 2011-10-12 23:47:44 -0700 | |
---|---|---|
committer | 2011-10-12 23:47:44 -0700 | |
commit | e4b15dcb45a9ca00397b037b28862adb5a4751ce (patch) | |
tree | b0ac9a8ac09c4feadee73a91b2b6e50a4cfdc2cd /java/src/com/android/inputmethod/latin/Utils.java | |
parent | eb903e7747cdf9d037f368ac73f42c9ba45f8fcc (diff) | |
parent | 22c2a23cdaa29c2de742d8ab3e8d7bf3c9f9564a (diff) | |
download | latinime-e4b15dcb45a9ca00397b037b28862adb5a4751ce.tar.gz latinime-e4b15dcb45a9ca00397b037b28862adb5a4751ce.tar.xz latinime-e4b15dcb45a9ca00397b037b28862adb5a4751ce.zip |
am 22c2a23c: am 605a6fea: Merge "Fix the safety net Bug: 5453150" into ics-mr0
* commit '22c2a23cdaa29c2de742d8ab3e8d7bf3c9f9564a':
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.java | 14 |
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(); } } |