aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-11-25 06:25:17 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-11-25 06:25:17 +0000
commit5af54d904a16c3949476d8f730263c15dee05cc8 (patch)
treeb2207e9dfb9a499df4a5b2460757cbe1e8ee15bc /java/src
parent58f5e62ba8e565880ae669aa7e167d022a3b89f6 (diff)
parentb479a56f281d7b20abbb05369a5d6d0a6ce9dc67 (diff)
downloadlatinime-5af54d904a16c3949476d8f730263c15dee05cc8.tar.gz
latinime-5af54d904a16c3949476d8f730263c15dee05cc8.tar.xz
latinime-5af54d904a16c3949476d8f730263c15dee05cc8.zip
am b479a56f: Merge "Add confidence."
* commit 'b479a56f281d7b20abbb05369a5d6d0a6ce9dc67': Add confidence.
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/DictionaryFacilitator.java32
1 files changed, 21 insertions, 11 deletions
diff --git a/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java b/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java
index b24fdea55..2ee4068b6 100644
--- a/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java
+++ b/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java
@@ -138,6 +138,10 @@ public class DictionaryFacilitator {
public final Locale mLocale;
private Dictionary mMainDict;
+ // Confidence that the most probable language is actually the language the user is
+ // typing in. For now, this is simply the number of times a word from this language
+ // has been committed in a row.
+ private int mConfidence = 0;
public float mWeightForTypingInLocale = WEIGHT_FOR_MOST_PROBABLE_LANGUAGE;
public float mWeightForGesturingInLocale = WEIGHT_FOR_MOST_PROBABLE_LANGUAGE;
public final ConcurrentHashMap<String, ExpandableBinaryDictionary> mSubDictMap =
@@ -260,8 +264,9 @@ public class DictionaryFacilitator {
public void switchMostProbableLanguage(final Locale locale) {
if (null == locale) {
// In many cases, there is no locale to a committed word. For example, a typed word
- // that does not auto-correct has no locale. In this case we simply do not change
- // the most probable language.
+ // that is in none of the currently active dictionaries but still does not
+ // auto-correct to anything has no locale. In this case we simply do not change
+ // the most probable language and do not touch confidence.
return;
}
final DictionaryGroup newMostProbableDictionaryGroup =
@@ -272,15 +277,20 @@ public class DictionaryFacilitator {
// facilitator any more. In this case, just not changing things is fine.
return;
}
- mMostProbableDictionaryGroup.mWeightForTypingInLocale =
- DictionaryGroup.WEIGHT_FOR_TYPING_IN_NOT_MOST_PROBABLE_LANGUAGE;
- mMostProbableDictionaryGroup.mWeightForGesturingInLocale =
- DictionaryGroup.WEIGHT_FOR_GESTURING_IN_NOT_MOST_PROBABLE_LANGUAGE;
- newMostProbableDictionaryGroup.mWeightForTypingInLocale =
- DictionaryGroup.WEIGHT_FOR_MOST_PROBABLE_LANGUAGE;
- newMostProbableDictionaryGroup.mWeightForGesturingInLocale =
- DictionaryGroup.WEIGHT_FOR_MOST_PROBABLE_LANGUAGE;
- mMostProbableDictionaryGroup = newMostProbableDictionaryGroup;
+ if (newMostProbableDictionaryGroup == mMostProbableDictionaryGroup) {
+ ++newMostProbableDictionaryGroup.mConfidence;
+ } else {
+ mMostProbableDictionaryGroup.mWeightForTypingInLocale =
+ DictionaryGroup.WEIGHT_FOR_TYPING_IN_NOT_MOST_PROBABLE_LANGUAGE;
+ mMostProbableDictionaryGroup.mWeightForGesturingInLocale =
+ DictionaryGroup.WEIGHT_FOR_GESTURING_IN_NOT_MOST_PROBABLE_LANGUAGE;
+ mMostProbableDictionaryGroup.mConfidence = 0;
+ newMostProbableDictionaryGroup.mWeightForTypingInLocale =
+ DictionaryGroup.WEIGHT_FOR_MOST_PROBABLE_LANGUAGE;
+ newMostProbableDictionaryGroup.mWeightForGesturingInLocale =
+ DictionaryGroup.WEIGHT_FOR_MOST_PROBABLE_LANGUAGE;
+ mMostProbableDictionaryGroup = newMostProbableDictionaryGroup;
+ }
}
@Nullable