aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/Suggest.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-02-05 13:33:12 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-02-05 13:33:12 +0000
commit58eed6360db7f8d2ba12ab34d18656f8ec7b6116 (patch)
tree0702af1c26413a494e388c99788b7fcb61f204c3 /java/src/com/android/inputmethod/latin/Suggest.java
parent239f7daf4a1fa9f83a4ce54a840c0fdc011f3b4c (diff)
parent5095fabdd0b9dcfd1af582d33792034763e612de (diff)
downloadlatinime-58eed6360db7f8d2ba12ab34d18656f8ec7b6116.tar.gz
latinime-58eed6360db7f8d2ba12ab34d18656f8ec7b6116.tar.xz
latinime-58eed6360db7f8d2ba12ab34d18656f8ec7b6116.zip
Merge "Stop considering personalization dicts outputs as words"
Diffstat (limited to 'java/src/com/android/inputmethod/latin/Suggest.java')
-rw-r--r--java/src/com/android/inputmethod/latin/Suggest.java22
1 files changed, 17 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index 439c8562e..bb938a99e 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -127,21 +127,33 @@ public final class Suggest {
mDictionaryFacilitator.getSuggestions(wordComposerForLookup, prevWordForBigram,
proximityInfo, blockOffensiveWords, additionalFeaturesOptions, SESSION_TYPING,
suggestionsSet);
+ final String firstSuggestion;
final String whitelistedWord;
if (suggestionsSet.isEmpty()) {
- whitelistedWord = null;
- } else if (SuggestedWordInfo.KIND_WHITELIST != suggestionsSet.first().mKind) {
- whitelistedWord = null;
+ whitelistedWord = firstSuggestion = null;
} else {
- whitelistedWord = suggestionsSet.first().mWord;
+ final SuggestedWordInfo firstSuggestedWordInfo = suggestionsSet.first();
+ firstSuggestion = firstSuggestedWordInfo.mWord;
+ if (SuggestedWordInfo.KIND_WHITELIST != firstSuggestedWordInfo.mKind) {
+ whitelistedWord = null;
+ } else {
+ whitelistedWord = firstSuggestion;
+ }
}
// 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).
+ // We allow auto-correction if we have a whitelisted word, or if the word is not a valid
+ // word of more than 1 char, except if the first suggestion is the same as the typed string
+ // because in this case if it's strong enough to auto-correct that will mistakenly designate
+ // the second candidate for auto-correction.
+ // TODO: stop relying on indices to find where is the auto-correction in the suggested
+ // words, and correct this test.
final boolean allowsToBeAutoCorrected = (null != whitelistedWord
&& !whitelistedWord.equals(consideredWord))
|| (consideredWord.length() > 1 && !mDictionaryFacilitator.isValidWord(
- consideredWord, wordComposer.isFirstCharCapitalized()));
+ consideredWord, wordComposer.isFirstCharCapitalized())
+ && !consideredWord.equals(firstSuggestion));
final boolean hasAutoCorrection;
// TODO: using isCorrectionEnabled here is not very good. It's probably useless, because