aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/Suggest.java
diff options
context:
space:
mode:
authorDan Zivkovic <zivkovic@google.com>2015-02-26 03:44:20 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-02-26 03:44:20 +0000
commite4619f029e84fd845b0771871218274b99c30ffa (patch)
treec3fec3f92f1ce678ae15c2157ac563ea048b9aa4 /java/src/com/android/inputmethod/latin/Suggest.java
parent48ba1ea19f7e18a24813a9301ed620612c2e53d7 (diff)
parent5551302d275e3f54da9d86bcea633556ad12db8e (diff)
downloadlatinime-e4619f029e84fd845b0771871218274b99c30ffa.tar.gz
latinime-e4619f029e84fd845b0771871218274b99c30ffa.tar.xz
latinime-e4619f029e84fd845b0771871218274b99c30ffa.zip
Merge "Don't assume that correctable words are invalid"
Diffstat (limited to 'java/src/com/android/inputmethod/latin/Suggest.java')
-rw-r--r--java/src/com/android/inputmethod/latin/Suggest.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index d4915a5e9..f4680fc88 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -210,7 +210,8 @@ public final class Suggest {
}
}
- SuggestedWordInfo.removeDups(typedWordString, suggestionsContainer);
+ final int firstOcurrenceOfTypedWordInSuggestions =
+ SuggestedWordInfo.removeDups(typedWordString, suggestionsContainer);
final SuggestedWordInfo whitelistedWordInfo =
getWhitelistedWordInfoOrNull(suggestionsContainer);
@@ -273,7 +274,8 @@ public final class Suggest {
hasAutoCorrection = false;
} else {
final SuggestedWordInfo firstSuggestion = suggestionResults.first();
- if (suggestionResults.mAutocorrectRecommendation) {
+ if (suggestionResults.mFirstSuggestionExceedsConfidenceThreshold
+ && firstOcurrenceOfTypedWordInSuggestions != 0) {
hasAutoCorrection = true;
} else if (!AutoCorrectionUtils.suggestionExceedsThreshold(
firstSuggestion, consideredWord, mAutoCorrectionThreshold)) {
@@ -314,12 +316,12 @@ public final class Suggest {
} else {
inputStyle = inputStyleIfNotPrediction;
}
+
+ final boolean isTypedWordValid = firstOcurrenceOfTypedWordInSuggestions > -1
+ || (!resultsArePredictions && !allowsToBeAutoCorrected);
callback.onGetSuggestedWords(new SuggestedWords(suggestionsList,
suggestionResults.mRawSuggestions, typedWordInfo,
- // 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.
- !resultsArePredictions && !allowsToBeAutoCorrected /* typedWordValid */,
+ isTypedWordValid,
hasAutoCorrection /* willAutoCorrect */,
false /* isObsoleteSuggestions */, inputStyle, sequenceNumber));
}