aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2011-04-22 13:08:35 +0900
committerJean Chalard <jchalard@google.com>2011-04-22 15:53:48 +0900
commitb50591295d7c4ff7bb46ddf3e609d0046eb64d18 (patch)
tree306a28d4a659881abf4de03c16d46094e6424ec6 /java/src
parent89bd776cf68150202d774d62cc1c88664aea5e9f (diff)
downloadlatinime-b50591295d7c4ff7bb46ddf3e609d0046eb64d18.tar.gz
latinime-b50591295d7c4ff7bb46ddf3e609d0046eb64d18.tar.xz
latinime-b50591295d7c4ff7bb46ddf3e609d0046eb64d18.zip
Add an option for using bigram prediction.
This change adds the option for bigram prediction under the option for bigram suggestion. The "prediction" option depends on the "suggestion" option. This change also reorders a tad bit the settings screen. Namely, it sticks both bigram options under a "bigram" category, and groups the options that did not have a group under a "other options", or misc, category. Finally this change also renames the internal name of the "text corrections" option category to "correction_category" instead of "prediction_category" which was misleading. Change-Id: I2d8787c8a391fd8202ed3a686c613494b7260a1e
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java9
-rw-r--r--java/src/com/android/inputmethod/latin/Settings.java21
2 files changed, 26 insertions, 4 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 8f44ec743..05691b224 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -177,7 +177,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
private boolean mJustAddedAutoSpace;
private boolean mAutoCorrectEnabled;
private boolean mRecorrectionEnabled;
+ // Suggestion: use bigrams to adjust scores of suggestions obtained from unigram dictionary
private boolean mBigramSuggestionEnabled;
+ // Prediction: use bigrams to predict the next word when there is no input for it yet
+ private boolean mBigramPredictionEnabled;
private boolean mAutoCorrectOn;
private boolean mVibrateOn;
private boolean mSoundOn;
@@ -2200,6 +2203,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mAutoCorrectEnabled = isAutoCorrectEnabled(prefs);
mBigramSuggestionEnabled = mAutoCorrectEnabled && isBigramSuggestionEnabled(prefs);
+ mBigramPredictionEnabled = mBigramSuggestionEnabled && isBigramPredictionEnabled(prefs);
loadAndSetAutoCorrectionThreshold(prefs);
mVoiceProxy.loadSettings(attribute, prefs);
@@ -2284,6 +2288,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
R.bool.config_default_bigram_suggestions));
}
+ private boolean isBigramPredictionEnabled(SharedPreferences sp) {
+ return sp.getBoolean(Settings.PREF_BIGRAM_PREDICTIONS, mResources.getBoolean(
+ R.bool.config_default_bigram_prediction));
+ }
+
private void initSuggestPuncList() {
if (mSuggestPuncs != null || mSuggestPuncList != null)
return;
diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java
index 6a0b7b009..42b0fadc2 100644
--- a/java/src/com/android/inputmethod/latin/Settings.java
+++ b/java/src/com/android/inputmethod/latin/Settings.java
@@ -62,13 +62,18 @@ public class Settings extends PreferenceActivity
public static final String PREF_SELECTED_LANGUAGES = "selected_languages";
public static final String PREF_SUBTYPES = "subtype_settings";
- public static final String PREF_PREDICTION_SETTINGS_KEY = "prediction_settings";
+ public static final String PREF_CORRECTION_SETTINGS_KEY = "correction_settings";
public static final String PREF_QUICK_FIXES = "quick_fixes";
public static final String PREF_SHOW_SUGGESTIONS_SETTING = "show_suggestions_setting";
public static final String PREF_AUTO_CORRECTION_THRESHOLD = "auto_correction_threshold";
- public static final String PREF_BIGRAM_SUGGESTIONS = "bigram_suggestion";
public static final String PREF_DEBUG_SETTINGS = "debug_settings";
+ public static final String PREF_NGRAM_SETTINGS_KEY = "ngram_settings";
+ public static final String PREF_BIGRAM_SUGGESTIONS = "bigram_suggestion";
+ public static final String PREF_BIGRAM_PREDICTIONS = "bigram_prediction";
+
+ public static final String PREF_MISC_SETTINGS_KEY = "misc_settings";
+
public static final String PREF_USABILITY_STUDY_MODE = "usability_study_mode";
// Dialog ids
@@ -80,7 +85,10 @@ public class Settings extends PreferenceActivity
private ListPreference mSettingsKeyPreference;
private ListPreference mShowCorrectionSuggestionsPreference;
private ListPreference mAutoCorrectionThreshold;
+ // Suggestion: use bigrams to adjust scores of suggestions obtained from unigram dictionary
private CheckBoxPreference mBigramSuggestion;
+ // Prediction: use bigrams to predict the next word when there is no input for it yet
+ private CheckBoxPreference mBigramPrediction;
private Preference mDebugSettingsPreference;
private boolean mVoiceOn;
@@ -96,6 +104,7 @@ public class Settings extends PreferenceActivity
R.string.auto_correction_threshold_mode_index_off);
final String currentSetting = mAutoCorrectionThreshold.getValue();
mBigramSuggestion.setEnabled(!currentSetting.equals(autoCorrectionOff));
+ mBigramPrediction.setEnabled(!currentSetting.equals(autoCorrectionOff));
}
@Override
@@ -119,6 +128,7 @@ public class Settings extends PreferenceActivity
mAutoCorrectionThreshold = (ListPreference) findPreference(PREF_AUTO_CORRECTION_THRESHOLD);
mBigramSuggestion = (CheckBoxPreference) findPreference(PREF_BIGRAM_SUGGESTIONS);
+ mBigramPrediction = (CheckBoxPreference) findPreference(PREF_BIGRAM_PREDICTIONS);
mDebugSettingsPreference = findPreference(PREF_DEBUG_SETTINGS);
if (mDebugSettingsPreference != null) {
final Intent debugSettingsIntent = new Intent(Intent.ACTION_MAIN);
@@ -131,7 +141,9 @@ public class Settings extends PreferenceActivity
final PreferenceGroup generalSettings =
(PreferenceGroup) findPreference(PREF_GENERAL_SETTINGS_KEY);
final PreferenceGroup textCorrectionGroup =
- (PreferenceGroup) findPreference(PREF_PREDICTION_SETTINGS_KEY);
+ (PreferenceGroup) findPreference(PREF_CORRECTION_SETTINGS_KEY);
+ final PreferenceGroup bigramGroup =
+ (PreferenceGroup) findPreference(PREF_NGRAM_SETTINGS_KEY);
final boolean showSettingsKeyOption = getResources().getBoolean(
R.bool.config_enable_show_settings_key_option);
@@ -178,6 +190,7 @@ public class Settings extends PreferenceActivity
R.bool.config_enable_bigram_suggestions_option);
if (!showBigramSuggestionsOption) {
textCorrectionGroup.removePreference(findPreference(PREF_BIGRAM_SUGGESTIONS));
+ textCorrectionGroup.removePreference(findPreference(PREF_BIGRAM_PREDICTIONS));
}
final boolean showUsabilityModeStudyOption = getResources().getBoolean(
@@ -192,7 +205,7 @@ public class Settings extends PreferenceActivity
super.onResume();
int autoTextSize = AutoText.getSize(getListView());
if (autoTextSize < 1) {
- ((PreferenceGroup) findPreference(PREF_PREDICTION_SETTINGS_KEY))
+ ((PreferenceGroup) findPreference(PREF_CORRECTION_SETTINGS_KEY))
.removePreference(mQuickFixes);
}
if (!VoiceProxy.VOICE_INSTALLED