diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin/personalization')
7 files changed, 116 insertions, 410 deletions
diff --git a/java/src/com/android/inputmethod/latin/personalization/ContextualDictionary.java b/java/src/com/android/inputmethod/latin/personalization/ContextualDictionary.java deleted file mode 100644 index ac55b9333..000000000 --- a/java/src/com/android/inputmethod/latin/personalization/ContextualDictionary.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.inputmethod.latin.personalization; - -import android.content.Context; - -import com.android.inputmethod.annotations.UsedForTesting; -import com.android.inputmethod.latin.Dictionary; -import com.android.inputmethod.latin.ExpandableBinaryDictionary; - -import java.io.File; -import java.util.Locale; - -public class ContextualDictionary extends ExpandableBinaryDictionary { - /* package */ static final String NAME = ContextualDictionary.class.getSimpleName(); - - private ContextualDictionary(final Context context, final Locale locale, - final File dictFile) { - super(context, getDictName(NAME, locale, dictFile), locale, Dictionary.TYPE_CONTEXTUAL, - dictFile); - // Always reset the contents. - clear(); - } - - @UsedForTesting - public static ContextualDictionary getDictionary(final Context context, final Locale locale, - final File dictFile, final String dictNamePrefix) { - return new ContextualDictionary(context, locale, dictFile); - } - - @Override - public boolean isValidWord(final String word) { - // Strings out of this dictionary should not be considered existing words. - return false; - } - - @Override - protected void loadInitialContentsLocked() { - } -} diff --git a/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java b/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java deleted file mode 100644 index 1ba7b366f..000000000 --- a/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.inputmethod.latin.personalization; - -import android.content.Context; - -import com.android.inputmethod.latin.Dictionary; -import com.android.inputmethod.latin.ExpandableBinaryDictionary; -import com.android.inputmethod.latin.makedict.DictionaryHeader; - -import java.io.File; -import java.util.Locale; -import java.util.Map; - -/** - * This class is a base class of a dictionary that supports decaying for the personalized language - * model. - */ -public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableBinaryDictionary { - private static final boolean DBG_DUMP_ON_CLOSE = false; - - /** Any pair being typed or picked */ - public static final int FREQUENCY_FOR_TYPED = 2; - - public static final int FREQUENCY_FOR_WORDS_IN_DICTS = FREQUENCY_FOR_TYPED; - public static final int FREQUENCY_FOR_WORDS_NOT_IN_DICTS = Dictionary.NOT_A_PROBABILITY; - - /** The locale for this dictionary. */ - public final Locale mLocale; - - protected DecayingExpandableBinaryDictionaryBase(final Context context, - final String dictName, final Locale locale, final String dictionaryType, - final File dictFile) { - super(context, dictName, locale, dictionaryType, dictFile); - mLocale = locale; - if (mLocale != null && mLocale.toString().length() > 1) { - reloadDictionaryIfRequired(); - } - } - - @Override - public void close() { - if (DBG_DUMP_ON_CLOSE) { - dumpAllWordsForDebug(); - } - // 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. - } - - /* package */ void runGCIfRequired() { - runGCIfRequired(false /* mindsBlockByGC */); - } - - @Override - public boolean isValidWord(final String word) { - // Strings out of this dictionary should not be considered existing words. - return false; - } -} diff --git a/java/src/com/android/inputmethod/latin/personalization/DictionaryDecayBroadcastReciever.java b/java/src/com/android/inputmethod/latin/personalization/DictionaryDecayBroadcastReciever.java deleted file mode 100644 index 221bb9a8f..000000000 --- a/java/src/com/android/inputmethod/latin/personalization/DictionaryDecayBroadcastReciever.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.inputmethod.latin.personalization; - -import android.app.AlarmManager; -import android.app.PendingIntent; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; - -import java.util.concurrent.TimeUnit; - -/** - * Broadcast receiver for periodically updating decaying dictionaries. - */ -public class DictionaryDecayBroadcastReciever extends BroadcastReceiver { - /** - * The root domain for the personalization. - */ - private static final String PERSONALIZATION_DOMAIN = - "com.android.inputmethod.latin.personalization"; - - /** - * The action of the intent to tell the time to decay dictionaries. - */ - private static final String DICTIONARY_DECAY_INTENT_ACTION = - PERSONALIZATION_DOMAIN + ".DICT_DECAY"; - - /** - * Interval to update for decaying dictionaries. - */ - /* package */ static final long DICTIONARY_DECAY_INTERVAL = TimeUnit.MINUTES.toMillis(60); - - public static void setUpIntervalAlarmForDictionaryDecaying(Context context) { - AlarmManager alarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); - final Intent updateIntent = new Intent(DICTIONARY_DECAY_INTENT_ACTION); - updateIntent.setClass(context, DictionaryDecayBroadcastReciever.class); - final long alarmTime = System.currentTimeMillis() + DICTIONARY_DECAY_INTERVAL; - final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0 /* requestCode */, - updateIntent, PendingIntent.FLAG_CANCEL_CURRENT); - if (null != alarmManager) alarmManager.setInexactRepeating(AlarmManager.RTC, - alarmTime, DICTIONARY_DECAY_INTERVAL, pendingIntent); - } - - @Override - public void onReceive(final Context context, final Intent intent) { - final String action = intent.getAction(); - if (action.equals(DICTIONARY_DECAY_INTENT_ACTION)) { - PersonalizationHelper.runGCOnAllOpenedUserHistoryDictionaries(); - PersonalizationHelper.runGCOnAllOpenedPersonalizationDictionaries(); - } - } -} diff --git a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDataChunk.java b/java/src/com/android/inputmethod/latin/personalization/PersonalizationDataChunk.java deleted file mode 100644 index 9d72de8c5..000000000 --- a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDataChunk.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.inputmethod.latin.personalization; - -import java.util.Collections; -import java.util.List; -import java.util.Locale; - -public class PersonalizationDataChunk { - public final boolean mInputByUser; - public final List<String> mTokens; - public final int mTimestampInSeconds; - public final String mPackageName; - public final Locale mlocale = null; - - public PersonalizationDataChunk(boolean inputByUser, final List<String> tokens, - final int timestampInSeconds, final String packageName) { - mInputByUser = inputByUser; - mTokens = Collections.unmodifiableList(tokens); - mTimestampInSeconds = timestampInSeconds; - mPackageName = packageName; - } -} diff --git a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionary.java b/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionary.java deleted file mode 100644 index f2ad22ac7..000000000 --- a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionary.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.inputmethod.latin.personalization; - -import android.content.Context; - -import com.android.inputmethod.annotations.UsedForTesting; -import com.android.inputmethod.latin.Dictionary; - -import java.io.File; -import java.util.Locale; - -public class PersonalizationDictionary extends DecayingExpandableBinaryDictionaryBase { - /* package */ static final String NAME = PersonalizationDictionary.class.getSimpleName(); - - // TODO: Make this constructor private - /* package */ PersonalizationDictionary(final Context context, final Locale locale) { - super(context, getDictName(NAME, locale, null /* dictFile */), locale, - Dictionary.TYPE_PERSONALIZATION, null /* dictFile */); - } - - @UsedForTesting - public static PersonalizationDictionary getDictionary(final Context context, - final Locale locale, final File dictFile, final String dictNamePrefix) { - return PersonalizationHelper.getPersonalizationDictionary(context, locale); - } -} diff --git a/java/src/com/android/inputmethod/latin/personalization/PersonalizationHelper.java b/java/src/com/android/inputmethod/latin/personalization/PersonalizationHelper.java index 331f85e0e..298e46c0a 100644 --- a/java/src/com/android/inputmethod/latin/personalization/PersonalizationHelper.java +++ b/java/src/com/android/inputmethod/latin/personalization/PersonalizationHelper.java @@ -19,130 +19,76 @@ package com.android.inputmethod.latin.personalization; import android.content.Context; import android.util.Log; -import com.android.inputmethod.latin.utils.FileUtils; +import com.android.inputmethod.latin.common.FileUtils; import java.io.File; import java.io.FilenameFilter; import java.lang.ref.SoftReference; import java.util.Locale; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Helps handle and manage personalized dictionaries such as {@link UserHistoryDictionary}. + */ public class PersonalizationHelper { private static final String TAG = PersonalizationHelper.class.getSimpleName(); private static final boolean DEBUG = false; + private static final ConcurrentHashMap<String, SoftReference<UserHistoryDictionary>> sLangUserHistoryDictCache = new ConcurrentHashMap<>(); - private static final ConcurrentHashMap<String, SoftReference<PersonalizationDictionary>> - sLangPersonalizationDictCache = new ConcurrentHashMap<>(); + @Nonnull public static UserHistoryDictionary getUserHistoryDictionary( - final Context context, final Locale locale) { - final String localeStr = locale.toString(); + final Context context, final Locale locale, @Nullable final String accountName) { + String lookupStr = locale.toString(); + if (accountName != null) { + lookupStr += "." + accountName; + } synchronized (sLangUserHistoryDictCache) { - if (sLangUserHistoryDictCache.containsKey(localeStr)) { + if (sLangUserHistoryDictCache.containsKey(lookupStr)) { final SoftReference<UserHistoryDictionary> ref = - sLangUserHistoryDictCache.get(localeStr); + sLangUserHistoryDictCache.get(lookupStr); final UserHistoryDictionary dict = ref == null ? null : ref.get(); if (dict != null) { if (DEBUG) { - Log.w(TAG, "Use cached UserHistoryDictionary for " + locale); + Log.d(TAG, "Use cached UserHistoryDictionary with lookup: " + lookupStr); } dict.reloadDictionaryIfRequired(); return dict; } } - final UserHistoryDictionary dict = new UserHistoryDictionary(context, locale); - sLangUserHistoryDictCache.put(localeStr, new SoftReference<>(dict)); - return dict; - } - } - - private static int sCurrentTimestampForTesting = 0; - public static void currentTimeChangedForTesting(final int currentTimestamp) { - if (TimeUnit.MILLISECONDS.toSeconds( - DictionaryDecayBroadcastReciever.DICTIONARY_DECAY_INTERVAL) - < currentTimestamp - sCurrentTimestampForTesting) { - runGCOnAllOpenedUserHistoryDictionaries(); - runGCOnAllOpenedPersonalizationDictionaries(); - } - } - - public static void runGCOnAllOpenedUserHistoryDictionaries() { - runGCOnAllDictionariesIfRequired(sLangUserHistoryDictCache); - } - - public static void runGCOnAllOpenedPersonalizationDictionaries() { - runGCOnAllDictionariesIfRequired(sLangPersonalizationDictCache); - } - - private static <T extends DecayingExpandableBinaryDictionaryBase> - void runGCOnAllDictionariesIfRequired( - final ConcurrentHashMap<String, SoftReference<T>> dictionaryMap) { - for (final ConcurrentHashMap.Entry<String, SoftReference<T>> entry - : dictionaryMap.entrySet()) { - final DecayingExpandableBinaryDictionaryBase dict = entry.getValue().get(); - if (dict != null) { - dict.runGCIfRequired(); - } else { - dictionaryMap.remove(entry.getKey()); - } - } - } - - public static PersonalizationDictionary getPersonalizationDictionary( - final Context context, final Locale locale) { - final String localeStr = locale.toString(); - synchronized (sLangPersonalizationDictCache) { - if (sLangPersonalizationDictCache.containsKey(localeStr)) { - final SoftReference<PersonalizationDictionary> ref = - sLangPersonalizationDictCache.get(localeStr); - final PersonalizationDictionary dict = ref == null ? null : ref.get(); - if (dict != null) { - if (DEBUG) { - Log.w(TAG, "Use cached PersonalizationDictionary for " + locale); - } - return dict; - } - } - final PersonalizationDictionary dict = new PersonalizationDictionary(context, locale); - sLangPersonalizationDictCache.put(localeStr, new SoftReference<>(dict)); + final UserHistoryDictionary dict = new UserHistoryDictionary( + context, locale, accountName); + sLangUserHistoryDictCache.put(lookupStr, new SoftReference<>(dict)); return dict; } } - public static void removeAllPersonalizationDictionaries(final Context context) { - removeAllDictionaries(context, sLangPersonalizationDictCache, - PersonalizationDictionary.NAME); - } - public static void removeAllUserHistoryDictionaries(final Context context) { - removeAllDictionaries(context, sLangUserHistoryDictCache, - UserHistoryDictionary.NAME); - } - - private static <T extends DecayingExpandableBinaryDictionaryBase> void removeAllDictionaries( - final Context context, final ConcurrentHashMap<String, SoftReference<T>> dictionaryMap, - final String dictNamePrefix) { - synchronized (dictionaryMap) { - for (final ConcurrentHashMap.Entry<String, SoftReference<T>> entry - : dictionaryMap.entrySet()) { + synchronized (sLangUserHistoryDictCache) { + for (final ConcurrentHashMap.Entry<String, SoftReference<UserHistoryDictionary>> entry + : sLangUserHistoryDictCache.entrySet()) { if (entry.getValue() != null) { - final DecayingExpandableBinaryDictionaryBase dict = entry.getValue().get(); + final UserHistoryDictionary dict = entry.getValue().get(); if (dict != null) { dict.clear(); } } } - dictionaryMap.clear(); + sLangUserHistoryDictCache.clear(); final File filesDir = context.getFilesDir(); if (filesDir == null) { Log.e(TAG, "context.getFilesDir() returned null."); return; } - if (!FileUtils.deleteFilteredFiles(filesDir, new DictFilter(dictNamePrefix))) { - Log.e(TAG, "Cannot remove all existing dictionary files. filesDir: " - + filesDir.getAbsolutePath() + ", dictNamePrefix: " + dictNamePrefix); + final boolean filesDeleted = FileUtils.deleteFilteredFiles( + filesDir, new DictFilter(UserHistoryDictionary.NAME)); + if (!filesDeleted) { + Log.e(TAG, "Cannot remove dictionary files. filesDir: " + filesDir.getAbsolutePath() + + ", dictNamePrefix: " + UserHistoryDictionary.NAME); } } } diff --git a/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java b/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java index 34d4d4ed7..cbf0829b5 100644 --- a/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java +++ b/java/src/com/android/inputmethod/latin/personalization/UserHistoryDictionary.java @@ -17,72 +17,120 @@ package com.android.inputmethod.latin.personalization; import android.content.Context; -import android.text.TextUtils; +import com.android.inputmethod.annotations.ExternallyReferenced; import com.android.inputmethod.annotations.UsedForTesting; -import com.android.inputmethod.latin.Constants; +import com.android.inputmethod.latin.BinaryDictionary; import com.android.inputmethod.latin.Dictionary; import com.android.inputmethod.latin.ExpandableBinaryDictionary; -import com.android.inputmethod.latin.PrevWordsInfo; -import com.android.inputmethod.latin.utils.DistracterFilter; +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; /** - * Locally gathers stats about the words user types and various other signals like auto-correction - * cancellation or manual picks. This allows the keyboard to adapt to the typist over time. + * Locally gathers statistics about the words user types and various other signals like + * auto-correction cancellation or manual picks. This allows the keyboard to adapt to the + * typist over time. */ -public class UserHistoryDictionary extends DecayingExpandableBinaryDictionaryBase { - /* package */ static final String NAME = UserHistoryDictionary.class.getSimpleName(); +public class UserHistoryDictionary extends ExpandableBinaryDictionary { + static final String NAME = UserHistoryDictionary.class.getSimpleName(); // TODO: Make this constructor private - /* package */ UserHistoryDictionary(final Context context, final Locale locale) { - super(context, getDictName(NAME, locale, null /* dictFile */), locale, - Dictionary.TYPE_USER_HISTORY, null /* dictFile */); + 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); + if (mLocale != null && mLocale.toString().length() > 1) { + reloadDictionaryIfRequired(); + } } + /** + * @returns the name of the {@link UserHistoryDictionary}. + */ @UsedForTesting + static String getUserHistoryDictName(final String name, final Locale locale, + @Nullable final File dictFile, @Nullable final String account) { + if (!ProductionFlags.ENABLE_PER_ACCOUNT_USER_HISTORY_DICTIONARY) { + return getDictName(name, locale, dictFile); + } + return getUserHistoryDictNamePerAccount(name, locale, dictFile, account); + } + + /** + * Uses the currently signed in account to determine the dictionary name. + */ + private static String getUserHistoryDictNamePerAccount(final String name, final Locale locale, + @Nullable final File dictFile, @Nullable final String account) { + if (dictFile != null) { + return dictFile.getName(); + } + String dictName = name + "." + locale.toString(); + if (account != null) { + dictName += "." + account; + } + return dictName; + } + + // Note: This method is called by {@link DictionaryFacilitator} using Java reflection. + @SuppressWarnings("unused") + @ExternallyReferenced public static UserHistoryDictionary getDictionary(final Context context, final Locale locale, - final File dictFile, final String dictNamePrefix) { - return PersonalizationHelper.getUserHistoryDictionary(context, locale); + final File dictFile, final String dictNamePrefix, @Nullable final String account) { + return PersonalizationHelper.getUserHistoryDictionary(context, locale, account); } /** * Add a word to the user history dictionary. * * @param userHistoryDictionary the user history dictionary - * @param prevWordsInfo the information of previous words + * @param ngramContext the n-gram context * @param word the word the user inputted * @param isValid whether the word is valid or not * @param timestamp the timestamp when the word has been inputted - * @param distracterFilter the filter to check whether the word is a distracter */ public static void addToDictionary(final ExpandableBinaryDictionary userHistoryDictionary, - final PrevWordsInfo prevWordsInfo, final String word, final boolean isValid, - final int timestamp, final DistracterFilter distracterFilter) { - final CharSequence prevWord = prevWordsInfo.mPrevWordsInfo[0].mWord; - if (word.length() > Constants.DICTIONARY_MAX_WORD_LENGTH || - (prevWord != null && prevWord.length() > Constants.DICTIONARY_MAX_WORD_LENGTH)) { - return; - } - final int frequency = isValid ? - FREQUENCY_FOR_WORDS_IN_DICTS : FREQUENCY_FOR_WORDS_NOT_IN_DICTS; - userHistoryDictionary.addUnigramEntryWithCheckingDistracter(word, frequency, - null /* shortcutTarget */, 0 /* shortcutFreq */, false /* isNotAWord */, - false /* isBlacklisted */, timestamp, distracterFilter); - // Do not insert a word as a bigram of itself - if (TextUtils.equals(word, prevWord)) { + @Nonnull final NgramContext ngramContext, final String word, final boolean isValid, + final int timestamp) { + if (word.length() > BinaryDictionary.DICTIONARY_MAX_WORD_LENGTH) { return; } - if (null != prevWord) { - if (prevWordsInfo.mPrevWordsInfo[0].mIsBeginningOfSentence) { - // Beginning-of-Sentence n-gram entry is treated as a n-gram entry of invalid word. - userHistoryDictionary.addNgramEntry(prevWordsInfo, word, - FREQUENCY_FOR_WORDS_NOT_IN_DICTS, timestamp); - } else { - userHistoryDictionary.addNgramEntry(prevWordsInfo, word, frequency, timestamp); - } - } + 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; } } |