Skip to content
Snippets Groups Projects
Commit 8c06a468 authored by Jean Chalard's avatar Jean Chalard
Browse files

Stop auto-correcting non-whitelisted one-char strings

Bug: 7134017
Change-Id: I75cf474dedafda3e1683dd8f7740c13aafdcf5ab
parent 29352761
No related branches found
No related tags found
No related merge requests found
...@@ -73,11 +73,11 @@ public class AutoCorrection { ...@@ -73,11 +73,11 @@ public class AutoCorrection {
return maxFreq; return maxFreq;
} }
// Returns true if this isn't in any dictionary. // Returns true if this is in any of the dictionaries.
public static boolean isNotAWord( public static boolean isInTheDictionary(
final ConcurrentHashMap<String, Dictionary> dictionaries, final ConcurrentHashMap<String, Dictionary> dictionaries,
final CharSequence word, final boolean ignoreCase) { final CharSequence word, final boolean ignoreCase) {
return !isValidWord(dictionaries, word, ignoreCase); return isValidWord(dictionaries, word, ignoreCase);
} }
public static boolean suggestionExceedsAutoCorrectionThreshold(SuggestedWordInfo suggestion, public static boolean suggestionExceedsAutoCorrectionThreshold(SuggestedWordInfo suggestion,
......
...@@ -214,10 +214,12 @@ public class Suggest { ...@@ -214,10 +214,12 @@ public class Suggest {
whitelistedWord = suggestionsSet.first().mWord; 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 final boolean allowsToBeAutoCorrected = (null != whitelistedWord
&& !whitelistedWord.equals(consideredWord)) && !whitelistedWord.equals(consideredWord))
|| AutoCorrection.isNotAWord(mDictionaries, consideredWord, || (consideredWord.length() > 1 && !AutoCorrection.isInTheDictionary(mDictionaries,
wordComposer.isFirstCharCapitalized()); consideredWord, wordComposer.isFirstCharCapitalized()));
final boolean hasAutoCorrection; final boolean hasAutoCorrection;
// TODO: using isCorrectionEnabled here is not very good. It's probably useless, because // TODO: using isCorrectionEnabled here is not very good. It's probably useless, because
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment