am d4528b88: Refactor personalization dictionary
* commit 'd4528b88e132ce2f25e45455a073b81385fcbd81': Refactor personalization dictionarymain
commit
44579790ad
|
@ -33,16 +33,14 @@ public class PersonalizationDictionaryHelper {
|
||||||
private static final ConcurrentHashMap<String, SoftReference<UserHistoryPredictionDictionary>>
|
private static final ConcurrentHashMap<String, SoftReference<UserHistoryPredictionDictionary>>
|
||||||
sLangUserHistoryDictCache = CollectionUtils.newConcurrentHashMap();
|
sLangUserHistoryDictCache = CollectionUtils.newConcurrentHashMap();
|
||||||
|
|
||||||
|
private static final ConcurrentHashMap<String, SoftReference<PersonalizationDictionary>>
|
||||||
|
sLangPersonalizationDictCache = CollectionUtils.newConcurrentHashMap();
|
||||||
|
|
||||||
private static final ConcurrentHashMap<String,
|
private static final ConcurrentHashMap<String,
|
||||||
SoftReference<PersonalizationPredictionDictionary>>
|
SoftReference<PersonalizationPredictionDictionary>>
|
||||||
sLangPersonalizationPredictionDictCache =
|
sLangPersonalizationPredictionDictCache =
|
||||||
CollectionUtils.newConcurrentHashMap();
|
CollectionUtils.newConcurrentHashMap();
|
||||||
|
|
||||||
private static final ConcurrentHashMap<String,
|
|
||||||
SoftReference<PersonalizationDictionary>>
|
|
||||||
sLangPersonalizationDictCache =
|
|
||||||
CollectionUtils.newConcurrentHashMap();
|
|
||||||
|
|
||||||
public static UserHistoryPredictionDictionary getUserHistoryPredictionDictionary(
|
public static UserHistoryPredictionDictionary getUserHistoryPredictionDictionary(
|
||||||
final Context context, final String locale, final SharedPreferences sp) {
|
final Context context, final String locale, final SharedPreferences sp) {
|
||||||
synchronized (sLangUserHistoryDictCache) {
|
synchronized (sLangUserHistoryDictCache) {
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin.personalization;
|
package com.android.inputmethod.latin.personalization;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.ExpandableBinaryDictionary;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
@ -49,9 +47,9 @@ public abstract class PersonalizationDictionaryUpdateSession {
|
||||||
// TODO: Use a dynamic binary dictionary instead
|
// TODO: Use a dynamic binary dictionary instead
|
||||||
public WeakReference<PersonalizationDictionary> mDictionary;
|
public WeakReference<PersonalizationDictionary> mDictionary;
|
||||||
public WeakReference<DynamicPredictionDictionaryBase> mPredictionDictionary;
|
public WeakReference<DynamicPredictionDictionaryBase> mPredictionDictionary;
|
||||||
public final String mLocale;
|
public final String mSystemLocale;
|
||||||
public PersonalizationDictionaryUpdateSession(String locale) {
|
public PersonalizationDictionaryUpdateSession(String locale) {
|
||||||
mLocale = locale;
|
mSystemLocale = locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void onDictionaryReady();
|
public abstract void onDictionaryReady();
|
||||||
|
@ -104,6 +102,7 @@ public abstract class PersonalizationDictionaryUpdateSession {
|
||||||
onDictionaryClosed(context);
|
onDictionaryClosed(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Support multi locale to add bigram
|
||||||
public void addBigramToPersonalizationDictionary(String word0, String word1, boolean isValid,
|
public void addBigramToPersonalizationDictionary(String word0, String word1, boolean isValid,
|
||||||
int frequency) {
|
int frequency) {
|
||||||
final DynamicPredictionDictionaryBase dictionary = getPredictionDictionary();
|
final DynamicPredictionDictionaryBase dictionary = getPredictionDictionary();
|
||||||
|
@ -114,6 +113,7 @@ public abstract class PersonalizationDictionaryUpdateSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bulk import
|
// Bulk import
|
||||||
|
// TODO: Support multi locale to add bigram
|
||||||
public void addBigramsToPersonalizationDictionary(
|
public void addBigramsToPersonalizationDictionary(
|
||||||
final ArrayList<PersonalizationLanguageModelParam> lmParams) {
|
final ArrayList<PersonalizationLanguageModelParam> lmParams) {
|
||||||
final DynamicPredictionDictionaryBase dictionary = getPredictionDictionary();
|
final DynamicPredictionDictionaryBase dictionary = getPredictionDictionary();
|
||||||
|
|
Loading…
Reference in New Issue