Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b5059129 authored by Jean Chalard's avatar Jean Chalard
Browse files

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
parent 89bd776c
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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>
+12 −2
Original line number Diff line number Diff line
@@ -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>
+35 −20
Original line number Diff line number Diff line
@@ -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,13 +90,27 @@
            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"
@@ -115,6 +129,7 @@
          android:entryValues="@array/keyboard_layout_modes_values"
          android:entries="@array/keyboard_layout_modes"
          android:defaultValue="@string/config_default_keyboard_theme_id" />
    </PreferenceCategory>
    <!-- <Preference
        android:title="Debug Settings"
        android:key="debug_settings">
+9 −0
Original line number Diff line number Diff line
@@ -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;
+17 −4
Original line number Diff line number Diff line
@@ -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