diff options
author | 2015-02-25 14:43:57 -0800 | |
---|---|---|
committer | 2015-02-25 20:13:59 -0800 | |
commit | 7d7f082075768c03e4b1d4b84ba2e6ef6cba1132 (patch) | |
tree | 069f512b6aa4076ad30206e8910b326303df3782 /java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java | |
parent | e4619f029e84fd845b0771871218274b99c30ffa (diff) | |
download | latinime-7d7f082075768c03e4b1d4b84ba2e6ef6cba1132.tar.gz latinime-7d7f082075768c03e4b1d4b84ba2e6ef6cba1132.tar.xz latinime-7d7f082075768c03e4b1d4b84ba2e6ef6cba1132.zip |
Stop waking up to decay dynamic dictionaries.
Bug 19516048.
Change-Id: Ibc27a792b4fa80fa8c6af4721c47a617526e9584
Diffstat (limited to 'java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java b/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java index b6286b203..54ee68d65 100644 --- a/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java +++ b/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java @@ -25,9 +25,11 @@ import com.android.inputmethod.latin.ExpandableBinaryDictionary; import com.android.inputmethod.latin.NgramContext; import com.android.inputmethod.latin.define.DecoderSpecificConstants; import com.android.inputmethod.latin.define.ProductionFlags; +import com.android.inputmethod.latin.makedict.DictionaryHeader; import java.io.File; import java.util.Locale; +import java.util.Map; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -37,17 +39,16 @@ import javax.annotation.Nullable; * auto-correction cancellation or manual picks. This allows the keyboard to adapt to the * typist over time. */ -public class UserHistoryDictionary extends DecayingExpandableBinaryDictionaryBase { +public class UserHistoryDictionary extends ExpandableBinaryDictionary { static final String NAME = UserHistoryDictionary.class.getSimpleName(); // TODO: Make this constructor private UserHistoryDictionary(final Context context, final Locale locale, @Nullable final String account) { - super(context, - getUserHistoryDictName(NAME, locale, null /* dictFile */, account), - locale, - Dictionary.TYPE_USER_HISTORY, - null /* dictFile */); + super(context, getUserHistoryDictName(NAME, locale, null /* dictFile */, account), locale, Dictionary.TYPE_USER_HISTORY, null); + if (mLocale != null && mLocale.toString().length() > 1) { + reloadDictionaryIfRequired(); + } } /** @@ -103,4 +104,32 @@ public class UserHistoryDictionary extends DecayingExpandableBinaryDictionaryBas userHistoryDictionary.updateEntriesForWord(ngramContext, word, isValid, 1 /* count */, timestamp); } + + @Override + public void close() { + // Flush pending writes. + asyncFlushBinaryDictionary(); + super.close(); + } + + @Override + protected Map<String, String> getHeaderAttributeMap() { + final Map<String, String> attributeMap = super.getHeaderAttributeMap(); + attributeMap.put(DictionaryHeader.USES_FORGETTING_CURVE_KEY, + DictionaryHeader.ATTRIBUTE_VALUE_TRUE); + attributeMap.put(DictionaryHeader.HAS_HISTORICAL_INFO_KEY, + DictionaryHeader.ATTRIBUTE_VALUE_TRUE); + return attributeMap; + } + + @Override + protected void loadInitialContentsLocked() { + // No initial contents. + } + + @Override + public boolean isValidWord(final String word) { + // Strings out of this dictionary should not be considered existing words. + return false; + } } |