Add a functionality to boost scores of personalization dictionary
Bug: 9429906 Change-Id: I1518c5cbc7d41188e7dc6a35d226da277ed5913f
This commit is contained in:
parent
66004ce2de
commit
d6ddb96ee8
6 changed files with 60 additions and 2 deletions
|
@ -493,6 +493,8 @@ mobile devices. [CHAR LIMIT=25] -->
|
|||
<string name="prefs_read_external_dictionary">Read external dictionary file</string>
|
||||
<!-- Title of the settings for using only personalization dictionary -->
|
||||
<string name="prefs_use_only_personalization_dictionary" translatable="false">Use only personalization dictionary</string>
|
||||
<!-- Title of the settings for boosting personalization dictionary -->
|
||||
<string name="prefs_boost_personalization_dictionary" translatable="false">Boost personalization dictionary</string>
|
||||
<!-- Message to show when there are no files to install as an external dictionary [CHAR LIMIT=100] -->
|
||||
<string name="read_external_dictionary_no_files_message">No dictionary files in the Downloads folder</string>
|
||||
<!-- Title of the dialog that selects a file to install as an external dictionary [CHAR LIMIT=50] -->
|
||||
|
|
|
@ -95,6 +95,7 @@ import com.android.inputmethod.latin.utils.RecapitalizeStatus;
|
|||
import com.android.inputmethod.latin.utils.StaticInnerHandlerWrapper;
|
||||
import com.android.inputmethod.latin.utils.TargetPackageInfoGetterTask;
|
||||
import com.android.inputmethod.latin.utils.TextRange;
|
||||
import com.android.inputmethod.latin.utils.UserHistoryForgettingCurveUtils;
|
||||
import com.android.inputmethod.research.ResearchLogger;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
|
@ -191,7 +192,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
private boolean mExpectingUpdateSelection;
|
||||
private int mDeleteCount;
|
||||
private long mLastKeyTime;
|
||||
private TreeSet<Long> mCurrentlyPressedHardwareKeys = CollectionUtils.newTreeSet();
|
||||
private final TreeSet<Long> mCurrentlyPressedHardwareKeys = CollectionUtils.newTreeSet();
|
||||
// Personalization debugging params
|
||||
private boolean mUseOnlyPersonalizationDictionaryForDebug = false;
|
||||
private boolean mBoostPersonalizationDictionaryForDebug = false;
|
||||
|
||||
// Member variables for remembering the current device orientation.
|
||||
private int mDisplayOrientation;
|
||||
|
@ -874,9 +878,35 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
// be replaced when the user dictionary reports back with the actual word, which ends
|
||||
// up calling #onWordAddedToUserDictionary() in this class.
|
||||
|
||||
initPersonalizationDebugSettings(currentSettingsValues);
|
||||
|
||||
if (TRACE) Debug.startMethodTracing("/data/trace/latinime");
|
||||
}
|
||||
|
||||
// Initialization of personalization debug settings. This must be called inside
|
||||
// onStartInputView.
|
||||
private void initPersonalizationDebugSettings(SettingsValues currentSettingsValues) {
|
||||
if (mUseOnlyPersonalizationDictionaryForDebug
|
||||
!= currentSettingsValues.mUseOnlyPersonalizationDictionaryForDebug) {
|
||||
// Only for debug
|
||||
initSuggest();
|
||||
mUseOnlyPersonalizationDictionaryForDebug =
|
||||
currentSettingsValues.mUseOnlyPersonalizationDictionaryForDebug;
|
||||
}
|
||||
|
||||
if (mBoostPersonalizationDictionaryForDebug !=
|
||||
currentSettingsValues.mBoostPersonalizationDictionaryForDebug) {
|
||||
// Only for debug
|
||||
mBoostPersonalizationDictionaryForDebug =
|
||||
currentSettingsValues.mBoostPersonalizationDictionaryForDebug;
|
||||
if (mBoostPersonalizationDictionaryForDebug) {
|
||||
UserHistoryForgettingCurveUtils.boostMaxFreqForDebug();
|
||||
} else {
|
||||
UserHistoryForgettingCurveUtils.resetMaxFreqForDebug();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Callback for the TargetPackageInfoGetterTask
|
||||
@Override
|
||||
public void onTargetPackageInfoKnown(final PackageInfo info) {
|
||||
|
|
|
@ -39,6 +39,8 @@ public final class DebugSettings extends PreferenceFragment
|
|||
public static final String PREF_STATISTICS_LOGGING = "enable_logging";
|
||||
public static final String PREF_USE_ONLY_PERSONALIZATION_DICTIONARY_FOR_DEBUG =
|
||||
"use_only_personalization_dictionary_for_debug";
|
||||
public static final String PREF_BOOST_PERSONALIZATION_DICTIONARY_FOR_DEBUG =
|
||||
"boost_personalization_dictionary_for_debug";
|
||||
private static final String PREF_READ_EXTERNAL_DICTIONARY = "read_external_dictionary";
|
||||
private static final boolean SHOW_STATISTICS_LOGGING = false;
|
||||
|
||||
|
|
|
@ -346,6 +346,12 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
|||
DebugSettings.PREF_USE_ONLY_PERSONALIZATION_DICTIONARY_FOR_DEBUG, false);
|
||||
}
|
||||
|
||||
public static boolean readBoostPersonalizationDictionaryForDebug(
|
||||
final SharedPreferences prefs) {
|
||||
return prefs.getBoolean(
|
||||
DebugSettings.PREF_BOOST_PERSONALIZATION_DICTIONARY_FOR_DEBUG, false);
|
||||
}
|
||||
|
||||
public void writeLastUsedPersonalizationToken(byte[] token) {
|
||||
final String tokenStr = StringUtils.byteArrayToHexString(token);
|
||||
mPrefs.edit().putString(PREF_LAST_USED_PERSONALIZATION_TOKEN, tokenStr).apply();
|
||||
|
|
|
@ -92,6 +92,8 @@ public final class SettingsValues {
|
|||
public final int mSuggestionVisibility;
|
||||
private final boolean mVoiceKeyEnabled;
|
||||
private final boolean mVoiceKeyOnMain;
|
||||
public final boolean mBoostPersonalizationDictionaryForDebug;
|
||||
public final boolean mUseOnlyPersonalizationDictionaryForDebug;
|
||||
|
||||
// Setting values for additional features
|
||||
public final int[] mAdditionalFeaturesSettingValues =
|
||||
|
@ -171,6 +173,10 @@ public final class SettingsValues {
|
|||
AdditionalFeaturesSettingUtils.readAdditionalFeaturesPreferencesIntoArray(
|
||||
prefs, mAdditionalFeaturesSettingValues);
|
||||
mIsInternal = Settings.isInternal(prefs);
|
||||
mBoostPersonalizationDictionaryForDebug =
|
||||
Settings.readBoostPersonalizationDictionaryForDebug(prefs);
|
||||
mUseOnlyPersonalizationDictionaryForDebug =
|
||||
Settings.readUseOnlyPersonalizationDictionaryForDebug(prefs);
|
||||
}
|
||||
|
||||
// Only for tests
|
||||
|
@ -216,6 +222,8 @@ public final class SettingsValues {
|
|||
mCorrectionEnabled = mAutoCorrectEnabled && !mInputAttributes.mInputTypeNoAutoCorrect;
|
||||
mSuggestionVisibility = 0;
|
||||
mIsInternal = false;
|
||||
mBoostPersonalizationDictionaryForDebug = false;
|
||||
mUseOnlyPersonalizationDictionaryForDebug = false;
|
||||
}
|
||||
|
||||
@UsedForTesting
|
||||
|
|
|
@ -23,7 +23,9 @@ import java.util.concurrent.TimeUnit;
|
|||
public final class UserHistoryForgettingCurveUtils {
|
||||
private static final String TAG = UserHistoryForgettingCurveUtils.class.getSimpleName();
|
||||
private static final boolean DEBUG = false;
|
||||
private static final int FC_FREQ_MAX = 127;
|
||||
private static final int DEFAULT_FC_FREQ = 127;
|
||||
private static final int BOOSTED_FC_FREQ = 200;
|
||||
private static int FC_FREQ_MAX = DEFAULT_FC_FREQ;
|
||||
/* package */ static final int COUNT_MAX = 3;
|
||||
private static final int FC_LEVEL_MAX = 3;
|
||||
/* package */ static final int ELAPSED_TIME_MAX = 15;
|
||||
|
@ -33,6 +35,14 @@ public final class UserHistoryForgettingCurveUtils {
|
|||
private static final int HALF_LIFE_HOURS = 48;
|
||||
private static final int MAX_PUSH_ELAPSED = (FC_LEVEL_MAX + 1) * (ELAPSED_TIME_MAX + 1);
|
||||
|
||||
public static void boostMaxFreqForDebug() {
|
||||
FC_FREQ_MAX = BOOSTED_FC_FREQ;
|
||||
}
|
||||
|
||||
public static void resetMaxFreqForDebug() {
|
||||
FC_FREQ_MAX = DEFAULT_FC_FREQ;
|
||||
}
|
||||
|
||||
private UserHistoryForgettingCurveUtils() {
|
||||
// This utility class is not publicly instantiable.
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue