aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/Suggest.java
diff options
context:
space:
mode:
authorDan Zivkovic <zivkovic@google.com>2015-02-25 15:57:59 -0800
committerDan Zivkovic <zivkovic@google.com>2015-02-25 17:59:58 -0800
commit5551302d275e3f54da9d86bcea633556ad12db8e (patch)
tree546240c21be53d829fe1521b6db126671e8e3594 /java/src/com/android/inputmethod/latin/Suggest.java
parented378c78a15757c7386d84c6cd7470d56ed00c76 (diff)
downloadlatinime-5551302d275e3f54da9d86bcea633556ad12db8e.tar.gz
latinime-5551302d275e3f54da9d86bcea633556ad12db8e.tar.xz
latinime-5551302d275e3f54da9d86bcea633556ad12db8e.zip
Don't assume that correctable words are invalid
Currently, the Delight3DictionaryFacilitator sets a boolean flag when the top suggestion score exceeds the auto-correction threshold. This flag is used to trigger auto-correction of the typed word. Also, the existing logic assumes that if allowsToBeAutoCorrected then the word is invalid, which is no longer true after we stopped using whitelists. Bug 19518376. Change-Id: Ifa7f6a09c07d25ac68c6cf3aec91f358bd88689f
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 832fcbcb0..dd4f51667 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -215,7 +215,8 @@ public final class Suggest {
}
}
- SuggestedWordInfo.removeDups(typedWordString, suggestionsContainer);
+ final int firstOcurrenceOfTypedWordInSuggestions =
+ SuggestedWordInfo.removeDups(typedWordString, suggestionsContainer);
final SuggestedWordInfo whitelistedWordInfo =
getWhitelistedWordInfoOrNull(suggestionsContainer);
@@ -278,7 +279,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)) {
@@ -319,12 +321,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));
}