Merge "Add a functionality to boost scores of personalization dictionary"
commit
33f5f0df8b
|
@ -493,6 +493,8 @@ mobile devices. [CHAR LIMIT=25] -->
|
||||||
<string name="prefs_read_external_dictionary">Read external dictionary file</string>
|
<string name="prefs_read_external_dictionary">Read external dictionary file</string>
|
||||||
<!-- Title of the settings for using only personalization dictionary -->
|
<!-- Title of the settings for using only personalization dictionary -->
|
||||||
<string name="prefs_use_only_personalization_dictionary" translatable="false">Use only personalization dictionary</string>
|
<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] -->
|
<!-- 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>
|
<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] -->
|
<!-- 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.StaticInnerHandlerWrapper;
|
||||||
import com.android.inputmethod.latin.utils.TargetPackageInfoGetterTask;
|
import com.android.inputmethod.latin.utils.TargetPackageInfoGetterTask;
|
||||||
import com.android.inputmethod.latin.utils.TextRange;
|
import com.android.inputmethod.latin.utils.TextRange;
|
||||||
|
import com.android.inputmethod.latin.utils.UserHistoryForgettingCurveUtils;
|
||||||
import com.android.inputmethod.research.ResearchLogger;
|
import com.android.inputmethod.research.ResearchLogger;
|
||||||
|
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
|
@ -191,7 +192,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
||||||
private boolean mExpectingUpdateSelection;
|
private boolean mExpectingUpdateSelection;
|
||||||
private int mDeleteCount;
|
private int mDeleteCount;
|
||||||
private long mLastKeyTime;
|
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.
|
// Member variables for remembering the current device orientation.
|
||||||
private int mDisplayOrientation;
|
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
|
// be replaced when the user dictionary reports back with the actual word, which ends
|
||||||
// up calling #onWordAddedToUserDictionary() in this class.
|
// up calling #onWordAddedToUserDictionary() in this class.
|
||||||
|
|
||||||
|
initPersonalizationDebugSettings(currentSettingsValues);
|
||||||
|
|
||||||
if (TRACE) Debug.startMethodTracing("/data/trace/latinime");
|
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
|
// Callback for the TargetPackageInfoGetterTask
|
||||||
@Override
|
@Override
|
||||||
public void onTargetPackageInfoKnown(final PackageInfo info) {
|
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_STATISTICS_LOGGING = "enable_logging";
|
||||||
public static final String PREF_USE_ONLY_PERSONALIZATION_DICTIONARY_FOR_DEBUG =
|
public static final String PREF_USE_ONLY_PERSONALIZATION_DICTIONARY_FOR_DEBUG =
|
||||||
"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 String PREF_READ_EXTERNAL_DICTIONARY = "read_external_dictionary";
|
||||||
private static final boolean SHOW_STATISTICS_LOGGING = false;
|
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);
|
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) {
|
public void writeLastUsedPersonalizationToken(byte[] token) {
|
||||||
final String tokenStr = StringUtils.byteArrayToHexString(token);
|
final String tokenStr = StringUtils.byteArrayToHexString(token);
|
||||||
mPrefs.edit().putString(PREF_LAST_USED_PERSONALIZATION_TOKEN, tokenStr).apply();
|
mPrefs.edit().putString(PREF_LAST_USED_PERSONALIZATION_TOKEN, tokenStr).apply();
|
||||||
|
|
|
@ -92,6 +92,8 @@ public final class SettingsValues {
|
||||||
public final int mSuggestionVisibility;
|
public final int mSuggestionVisibility;
|
||||||
private final boolean mVoiceKeyEnabled;
|
private final boolean mVoiceKeyEnabled;
|
||||||
private final boolean mVoiceKeyOnMain;
|
private final boolean mVoiceKeyOnMain;
|
||||||
|
public final boolean mBoostPersonalizationDictionaryForDebug;
|
||||||
|
public final boolean mUseOnlyPersonalizationDictionaryForDebug;
|
||||||
|
|
||||||
// Setting values for additional features
|
// Setting values for additional features
|
||||||
public final int[] mAdditionalFeaturesSettingValues =
|
public final int[] mAdditionalFeaturesSettingValues =
|
||||||
|
@ -171,6 +173,10 @@ public final class SettingsValues {
|
||||||
AdditionalFeaturesSettingUtils.readAdditionalFeaturesPreferencesIntoArray(
|
AdditionalFeaturesSettingUtils.readAdditionalFeaturesPreferencesIntoArray(
|
||||||
prefs, mAdditionalFeaturesSettingValues);
|
prefs, mAdditionalFeaturesSettingValues);
|
||||||
mIsInternal = Settings.isInternal(prefs);
|
mIsInternal = Settings.isInternal(prefs);
|
||||||
|
mBoostPersonalizationDictionaryForDebug =
|
||||||
|
Settings.readBoostPersonalizationDictionaryForDebug(prefs);
|
||||||
|
mUseOnlyPersonalizationDictionaryForDebug =
|
||||||
|
Settings.readUseOnlyPersonalizationDictionaryForDebug(prefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only for tests
|
// Only for tests
|
||||||
|
@ -216,6 +222,8 @@ public final class SettingsValues {
|
||||||
mCorrectionEnabled = mAutoCorrectEnabled && !mInputAttributes.mInputTypeNoAutoCorrect;
|
mCorrectionEnabled = mAutoCorrectEnabled && !mInputAttributes.mInputTypeNoAutoCorrect;
|
||||||
mSuggestionVisibility = 0;
|
mSuggestionVisibility = 0;
|
||||||
mIsInternal = false;
|
mIsInternal = false;
|
||||||
|
mBoostPersonalizationDictionaryForDebug = false;
|
||||||
|
mUseOnlyPersonalizationDictionaryForDebug = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@UsedForTesting
|
@UsedForTesting
|
||||||
|
|
|
@ -23,7 +23,9 @@ import java.util.concurrent.TimeUnit;
|
||||||
public final class UserHistoryForgettingCurveUtils {
|
public final class UserHistoryForgettingCurveUtils {
|
||||||
private static final String TAG = UserHistoryForgettingCurveUtils.class.getSimpleName();
|
private static final String TAG = UserHistoryForgettingCurveUtils.class.getSimpleName();
|
||||||
private static final boolean DEBUG = false;
|
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;
|
/* package */ static final int COUNT_MAX = 3;
|
||||||
private static final int FC_LEVEL_MAX = 3;
|
private static final int FC_LEVEL_MAX = 3;
|
||||||
/* package */ static final int ELAPSED_TIME_MAX = 15;
|
/* 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 HALF_LIFE_HOURS = 48;
|
||||||
private static final int MAX_PUSH_ELAPSED = (FC_LEVEL_MAX + 1) * (ELAPSED_TIME_MAX + 1);
|
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() {
|
private UserHistoryForgettingCurveUtils() {
|
||||||
// This utility class is not publicly instantiable.
|
// This utility class is not publicly instantiable.
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue