diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/res/values/config.xml | 5 | ||||
-rw-r--r-- | java/res/values/strings.xml | 14 | ||||
-rw-r--r-- | java/res/xml/prefs.xml | 55 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 9 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/Settings.java | 21 |
5 files changed, 78 insertions, 26 deletions
diff --git a/java/res/values/config.xml b/java/res/values/config.xml index 300aaa423..77259b1dc 100644 --- a/java/res/values/config.xml +++ b/java/res/values/config.xml @@ -37,7 +37,12 @@ <bool name="config_default_popup_preview">true</bool> <!-- Default values for whether quick fixes and bigram suggestions are activated --> <bool name="config_default_quick_fixes">true</bool> + <!-- Default value for bigram suggestion: while showing candidates for a word should we weigh + in the previous word? --> <bool name="config_default_bigram_suggestions">true</bool> + <!-- Default value for bigram prediction: after entering a word and a space only, should we look + at input history to suggest a hopefully helpful candidate for the next word? --> + <bool name="config_default_bigram_prediction">false</bool> <bool name="config_default_recorrection_enabled">true</bool> <bool name="config_default_sound_enabled">false</bool> <bool name="config_use_spacebar_language_switcher">true</bool> diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index 66dc7d71c..cfad5b118 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -38,7 +38,13 @@ <string name="general_category">General</string> <!-- Category title for text prediction --> - <string name="prediction_category">Text correction</string> + <string name="correction_category">Text correction</string> + + <!-- Category title for ngrams --> + <string name="ngram_category">Suggestions based on previous words</string> + + <!-- Category title for misc options --> + <string name="misc_category">Other options</string> <!-- Option to enable auto capitalization of sentences --> <string name="auto_cap">Auto-capitalization</string> @@ -78,9 +84,13 @@ <string name="auto_correction_threshold_mode_aggeressive">Aggressive</string> <!-- Option to enable bigram correction --> - <string name="bigram_suggestion">Bigram Suggestions</string> + <string name="bigram_suggestion">Bigram suggestions</string> <!-- Description for auto correction --> <string name="bigram_suggestion_summary">Use previous word to improve suggestion</string> + <!-- Option to enable using user-history bigram when no input --> + <string name="bigram_prediction">Bigram prediction</string> + <!-- Description for auto correction --> + <string name="bigram_prediction_summary">Use previous word also for prediction</string> <!-- Indicates that a word has been added to the dictionary --> <string name="added_word"><xliff:g id="word">%s</xliff:g> : Saved</string> diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml index cbfc3c39d..24a1d45a5 100644 --- a/java/res/xml/prefs.xml +++ b/java/res/xml/prefs.xml @@ -66,8 +66,8 @@ android:summary="@string/language_selection_summary" /> </PreferenceCategory> <PreferenceCategory - android:title="@string/prediction_category" - android:key="prediction_settings"> + android:title="@string/correction_category" + android:key="correction_settings"> <CheckBoxPreference android:key="quick_fixes" android:title="@string/quick_fixes" @@ -90,31 +90,46 @@ android:entryValues="@array/prefs_suggestion_visibility_values" android:entries="@array/prefs_suggestion_visibilities" android:defaultValue="@string/prefs_suggestion_visibility_default_value" /> + </PreferenceCategory> + <PreferenceCategory + android:title="@string/ngram_category" + android:key="ngram_settings"> <CheckBoxPreference android:key="bigram_suggestion" android:title="@string/bigram_suggestion" android:summary="@string/bigram_suggestion_summary" android:persistent="true" android:defaultValue="true" /> + <CheckBoxPreference + android:key="bigram_prediction" + android:dependency="bigram_suggestion" + android:title="@string/bigram_prediction" + android:summary="@string/bigram_prediction_summary" + android:persistent="true" + android:defaultValue="false" /> + </PreferenceCategory> + <PreferenceCategory + android:title="@string/misc_category" + android:key="misc_settings"> + <CheckBoxPreference + android:key="usability_study_mode" + android:title="@string/prefs_usability_study_mode" + android:persistent="true" + android:defaultValue="false" /> + <CheckBoxPreference + android:key="enable_logging" + android:title="@string/prefs_enable_log" + android:summary="@string/prefs_description_log" + android:persistent="true" + android:defaultValue="true" /> + <ListPreference + android:key="pref_keyboard_layout_20100902" + android:title="@string/keyboard_layout" + android:persistent="true" + android:entryValues="@array/keyboard_layout_modes_values" + android:entries="@array/keyboard_layout_modes" + android:defaultValue="@string/config_default_keyboard_theme_id" /> </PreferenceCategory> - <CheckBoxPreference - android:key="usability_study_mode" - android:title="@string/prefs_usability_study_mode" - android:persistent="true" - android:defaultValue="false" /> - <CheckBoxPreference - android:key="enable_logging" - android:title="@string/prefs_enable_log" - android:summary="@string/prefs_description_log" - android:persistent="true" - android:defaultValue="true" /> - <ListPreference - android:key="pref_keyboard_layout_20100902" - android:title="@string/keyboard_layout" - android:persistent="true" - android:entryValues="@array/keyboard_layout_modes_values" - android:entries="@array/keyboard_layout_modes" - android:defaultValue="@string/config_default_keyboard_theme_id" /> <!-- <Preference android:title="Debug Settings" android:key="debug_settings"> 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 |