diff --git a/java/src/com/android/inputmethod/latin/AutoCorrection.java b/java/src/com/android/inputmethod/latin/AutoCorrection.java index 4ae12145c..91e1dddec 100644 --- a/java/src/com/android/inputmethod/latin/AutoCorrection.java +++ b/java/src/com/android/inputmethod/latin/AutoCorrection.java @@ -31,22 +31,6 @@ public class AutoCorrection { // Purely static class: can't instantiate. } - public static CharSequence computeAutoCorrectionWord( - final ConcurrentHashMap dictionaries, - final WordComposer wordComposer, SuggestedWordInfo suggestion, - final CharSequence consideredWord, final float autoCorrectionThreshold, - final CharSequence whitelistedWord) { - if (hasAutoCorrectionForWhitelistedWord(whitelistedWord)) { - return whitelistedWord; - } else if (shouldAutoCorrectToSelf(dictionaries, consideredWord)) { - return consideredWord; - } else if (hasAutoCorrectionForBinaryDictionary(suggestion, - consideredWord, autoCorrectionThreshold)) { - return suggestion.mWord; - } - return null; - } - public static boolean isValidWord(final ConcurrentHashMap dictionaries, CharSequence word, boolean ignoreCase) { if (TextUtils.isEmpty(word)) { @@ -104,18 +88,18 @@ public class AutoCorrection { return !isValidWord(dictionaries, word, ignoreCase); } - private static boolean hasAutoCorrectionForWhitelistedWord(CharSequence whiteListedWord) { + static public boolean hasAutoCorrectionForWhitelistedWord(CharSequence whiteListedWord) { return whiteListedWord != null; } - private static boolean shouldAutoCorrectToSelf( + public static boolean shouldAutoCorrectToSelf( final ConcurrentHashMap dictionaries, final CharSequence consideredWord) { if (TextUtils.isEmpty(consideredWord)) return false; return !allowsToBeAutoCorrected(dictionaries, consideredWord, false); } - private static boolean hasAutoCorrectionForBinaryDictionary(SuggestedWordInfo suggestion, + public static boolean hasAutoCorrectionForBinaryDictionary(SuggestedWordInfo suggestion, CharSequence consideredWord, float autoCorrectionThreshold) { if (null != suggestion) { //final int autoCorrectionSuggestionScore = sortedScores[0]; diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 2d388e180..195c19b4d 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -230,10 +230,17 @@ public class Suggest { if (isCorrectionEnabled) { final SuggestedWordInfo bestSuggestion = suggestionsSet.isEmpty() ? null : suggestionsSet.first(); - final CharSequence autoCorrection = - AutoCorrection.computeAutoCorrectionWord(mDictionaries, wordComposer, - bestSuggestion, consideredWord, mAutoCorrectionThreshold, - whitelistedWord); + final CharSequence autoCorrection; + if (AutoCorrection.hasAutoCorrectionForWhitelistedWord(whitelistedWord)) { + autoCorrection = whitelistedWord; + } else if (AutoCorrection.shouldAutoCorrectToSelf(mDictionaries, consideredWord)) { + autoCorrection = consideredWord; + } else if (AutoCorrection.hasAutoCorrectionForBinaryDictionary(bestSuggestion, + consideredWord, mAutoCorrectionThreshold)) { + autoCorrection = bestSuggestion.mWord; + } else { + autoCorrection = null; + } hasAutoCorrection = (null != autoCorrection); } else { hasAutoCorrection = false;