diff options
author | 2014-11-26 08:37:27 +0000 | |
---|---|---|
committer | 2014-11-26 08:37:27 +0000 | |
commit | 9ab179a14247a91110940c3fe27da4004e6b952f (patch) | |
tree | 1e637ebaae0cd4a79dd9851d7df7d806ee2d7699 /java/src/com/android/inputmethod/latin/Suggest.java | |
parent | adb4f0ed2099b46ca89c57bc56e3863a28d12982 (diff) | |
parent | e752aab70dc15c993a65d7db8314a72bb9e0f8b2 (diff) | |
download | latinime-9ab179a14247a91110940c3fe27da4004e6b952f.tar.gz latinime-9ab179a14247a91110940c3fe27da4004e6b952f.tar.xz latinime-9ab179a14247a91110940c3fe27da4004e6b952f.zip |
am e752aab7: Use confidence to fix whitelist
* commit 'e752aab70dc15c993a65d7db8314a72bb9e0f8b2':
Use confidence to fix whitelist
Diffstat (limited to 'java/src/com/android/inputmethod/latin/Suggest.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/Suggest.java | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 2d0ec42a6..93a21043c 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -32,6 +32,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Locale; +import javax.annotation.Nonnull; import javax.annotation.Nullable; /** @@ -117,7 +118,8 @@ public final class Suggest { return suggestionsContainer; } - private static String getWhitelistedWordOrNull(final ArrayList<SuggestedWordInfo> suggestions) { + private static SuggestedWordInfo getWhitelistedWordInfoOrNull( + @Nonnull final ArrayList<SuggestedWordInfo> suggestions) { if (suggestions.isEmpty()) { return null; } @@ -125,7 +127,7 @@ public final class Suggest { if (!firstSuggestedWordInfo.isKindOf(SuggestedWordInfo.KIND_WHITELIST)) { return null; } - return firstSuggestedWordInfo.mWord; + return firstSuggestedWordInfo; } // Retrieves suggestions for non-batch input (typing, recorrection, predictions...) @@ -156,7 +158,18 @@ public final class Suggest { SuggestedWordInfo.removeDupsAndReturnSourceOfTypedWord(wordComposer.getTypedWord(), mostProbableLocale /* preferredLocale */, suggestionsContainer); - final String whitelistedWord = getWhitelistedWordOrNull(suggestionsContainer); + final SuggestedWordInfo whitelistedWordInfo = + getWhitelistedWordInfoOrNull(suggestionsContainer); + final String whitelistedWord; + if (null != whitelistedWordInfo && + mDictionaryFacilitator.isConfidentAboutCurrentLanguageBeing( + whitelistedWordInfo.mSourceDict.mLocale)) { + whitelistedWord = whitelistedWordInfo.mWord; + } else { + // Even if we have a whitelist candidate, we don't use it unless we are confident + // the user is typing in the language this whitelist candidate comes from. + whitelistedWord = null; + } final boolean resultsArePredictions = !wordComposer.isComposingWord(); // We allow auto-correction if we have a whitelisted word, or if the word had more than |