aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/Suggest.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/Suggest.java')
-rw-r--r--java/src/com/android/inputmethod/latin/Suggest.java35
1 files changed, 17 insertions, 18 deletions
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index 2d388e180..952296227 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -227,14 +227,19 @@ public class Suggest {
mWhiteListDictionary.getWhitelistedWord(consideredWord);
final boolean hasAutoCorrection;
- if (isCorrectionEnabled) {
- final SuggestedWordInfo bestSuggestion = suggestionsSet.isEmpty()
- ? null : suggestionsSet.first();
- final CharSequence autoCorrection =
- AutoCorrection.computeAutoCorrectionWord(mDictionaries, wordComposer,
- bestSuggestion, consideredWord, mAutoCorrectionThreshold,
- whitelistedWord);
- hasAutoCorrection = (null != autoCorrection);
+ if (!isCorrectionEnabled) {
+ hasAutoCorrection = false;
+ } else if (null != whitelistedWord) {
+ hasAutoCorrection = true;
+ } else if (!AutoCorrection.isWhitelistedOrNotAWord(
+ mDictionaries, consideredWord, wordComposer.isFirstCharCapitalized())) {
+ hasAutoCorrection = true;
+ } else if (suggestionsSet.isEmpty()) {
+ hasAutoCorrection = false;
+ } else if (AutoCorrection.suggestionExceedsAutoCorrectionThreshold(suggestionsSet.first(),
+ consideredWord, mAutoCorrectionThreshold)) {
+ hasAutoCorrection = !shouldBlockAutoCorrectionBySafetyNet(typedWord,
+ suggestionsSet.first().mWord);
} else {
hasAutoCorrection = false;
}
@@ -282,7 +287,7 @@ public class Suggest {
// The whitelist should be case-insensitive, so it's not possible to be consistent with
// a boolean flag. Right now this is handled with a slight hack in
// WhitelistDictionary#shouldForciblyAutoCorrectFrom.
- final boolean allowsToBeAutoCorrected = AutoCorrection.allowsToBeAutoCorrected(
+ final boolean allowsToBeAutoCorrected = AutoCorrection.isWhitelistedOrNotAWord(
getUnigramDictionaries(), consideredWord, wordComposer.isFirstCharCapitalized())
// If we don't have a main dictionary, we never want to auto-correct. The reason for this
// is, the user may have a contact whose name happens to match a valid word in their
@@ -292,21 +297,15 @@ public class Suggest {
&& hasMainDictionary();
boolean autoCorrectionAvailable = hasAutoCorrection;
- if (isCorrectionEnabled) {
- autoCorrectionAvailable |= !allowsToBeAutoCorrected;
- }
// Don't auto-correct words with multiple capital letter
autoCorrectionAvailable &= !wordComposer.isMostlyCaps();
autoCorrectionAvailable &= !wordComposer.isResumed();
- if (allowsToBeAutoCorrected && suggestionsList.size() > 1 && mAutoCorrectionThreshold > 0
- && Suggest.shouldBlockAutoCorrectionBySafetyNet(typedWord,
- suggestionsList.get(1).mWord)) {
- autoCorrectionAvailable = false;
- }
return new SuggestedWords(suggestionsList,
+ // TODO: this first argument is lying. If this is a whitelisted word which is an
+ // actual word, it says typedWordValid = false, which looks wrong. We should either
+ // rename the attribute or change the value.
!isPrediction && !allowsToBeAutoCorrected /* typedWordValid */,
!isPrediction && autoCorrectionAvailable /* hasAutoCorrectionCandidate */,
- !isPrediction && allowsToBeAutoCorrected /* allowsToBeAutoCorrected */,
false /* isPunctuationSuggestions */,
false /* isObsoleteSuggestions */,
isPrediction);