diff --git a/java/src/com/android/inputmethod/latin/AutoCorrection.java b/java/src/com/android/inputmethod/latin/AutoCorrection.java index 01ba300770f7111a5768eba067ff03ce33457808..f425e360ab9afae225ad1c73de94f3a642b3a3e7 100644 --- a/java/src/com/android/inputmethod/latin/AutoCorrection.java +++ b/java/src/com/android/inputmethod/latin/AutoCorrection.java @@ -73,11 +73,11 @@ public class AutoCorrection { return maxFreq; } - // Returns true if this isn't in any dictionary. - public static boolean isNotAWord( + // Returns true if this is in any of the dictionaries. + public static boolean isInTheDictionary( final ConcurrentHashMap<String, Dictionary> dictionaries, final CharSequence word, final boolean ignoreCase) { - return !isValidWord(dictionaries, word, ignoreCase); + return isValidWord(dictionaries, word, ignoreCase); } public static boolean suggestionExceedsAutoCorrectionThreshold(SuggestedWordInfo suggestion, diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 51ed096049ba3191869e5d76ee44fda584f48fbe..f922bc9e0b9a938ad3572041b7ed5faed0b8bcd3 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -214,10 +214,12 @@ public class Suggest { whitelistedWord = suggestionsSet.first().mWord; } + // The word can be auto-corrected if it has a whitelist entry that is not itself, + // or if it's a 2+ characters non-word (i.e. it's not in the dictionary). final boolean allowsToBeAutoCorrected = (null != whitelistedWord && !whitelistedWord.equals(consideredWord)) - || AutoCorrection.isNotAWord(mDictionaries, consideredWord, - wordComposer.isFirstCharCapitalized()); + || (consideredWord.length() > 1 && !AutoCorrection.isInTheDictionary(mDictionaries, + consideredWord, wordComposer.isFirstCharCapitalized())); final boolean hasAutoCorrection; // TODO: using isCorrectionEnabled here is not very good. It's probably useless, because