diff options
author | 2014-11-21 18:56:55 +0900 | |
---|---|---|
committer | 2014-11-26 17:29:59 +0900 | |
commit | e752aab70dc15c993a65d7db8314a72bb9e0f8b2 (patch) | |
tree | db0d4e46b4a0e9200c546e34c64148736720ad8b /java/src/com/android/inputmethod/latin/DictionaryFacilitator.java | |
parent | 20da4f07be9cdf58835a79e619785b4cafd428ff (diff) | |
download | latinime-e752aab70dc15c993a65d7db8314a72bb9e0f8b2.tar.gz latinime-e752aab70dc15c993a65d7db8314a72bb9e0f8b2.tar.xz latinime-e752aab70dc15c993a65d7db8314a72bb9e0f8b2.zip |
Use confidence to fix whitelist
With this the most obvious problem is fixed. However there
are two remaining items : we should still enforce whitelist
when there are no close candidates at all, and we should
start in confident mode when pressing the globe key.
Bug: 18063142
Bug: 18130489
Bug: 18132240
Bug: 18136721
Bug: 18200415
Change-Id: Ibc0571ae35fc28f8d13760aa86b25db1163d3e31
Diffstat (limited to 'java/src/com/android/inputmethod/latin/DictionaryFacilitator.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/DictionaryFacilitator.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java b/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java index 2ee4068b6..f2d7a8c3c 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java +++ b/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java @@ -63,6 +63,9 @@ public class DictionaryFacilitator { // HACK: This threshold is being used when adding a capitalized entry in the User History // dictionary. private static final int CAPITALIZED_FORM_MAX_PROBABILITY_FOR_INSERT = 140; + // How many words we need to type in a row ({@see mConfidenceInMostProbableLanguage}) to + // declare we are confident the user is typing in the most probable language. + private static final int CONFIDENCE_THRESHOLD = 3; private DictionaryGroup[] mDictionaryGroups = new DictionaryGroup[] { new DictionaryGroup() }; private DictionaryGroup mMostProbableDictionaryGroup = mDictionaryGroups[0]; @@ -293,6 +296,14 @@ public class DictionaryFacilitator { } } + public boolean isConfidentAboutCurrentLanguageBeing(final Locale mLocale) { + final DictionaryGroup mostProbableDictionaryGroup = mMostProbableDictionaryGroup; + if (!mostProbableDictionaryGroup.mLocale.equals(mLocale)) { + return false; + } + return mostProbableDictionaryGroup.mConfidence >= CONFIDENCE_THRESHOLD; + } + @Nullable private static ExpandableBinaryDictionary getSubDict(final String dictType, final Context context, final Locale locale, final File dictFile, @@ -634,7 +645,8 @@ public class DictionaryFacilitator { final int timeStampInSeconds, final boolean blockPotentiallyOffensive) { final ExpandableBinaryDictionary userHistoryDictionary = dictionaryGroup.getSubDict(Dictionary.TYPE_USER_HISTORY); - if (userHistoryDictionary == null) { + if (userHistoryDictionary == null + || !isConfidentAboutCurrentLanguageBeing(userHistoryDictionary.mLocale)) { return; } final int maxFreq = getFrequency(word); |