diff options
author | 2011-09-29 21:07:22 +0900 | |
---|---|---|
committer | 2011-09-30 16:00:07 +0900 | |
commit | 673cebf9e97289b3b0cd343ff7193dff69684a48 (patch) | |
tree | c8f7c1c333406080f3b830456f09e949cf1e05f8 /java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java | |
parent | db096d681f40b8547b4ce83d07d8d8b54e30634e (diff) | |
download | latinime-673cebf9e97289b3b0cd343ff7193dff69684a48.tar.gz latinime-673cebf9e97289b3b0cd343ff7193dff69684a48.tar.xz latinime-673cebf9e97289b3b0cd343ff7193dff69684a48.zip |
Make use of the FULL_EDIT_DISTANCE flag.
In effect, this stops the spell checker from suggesting overly
long words.
More precisely, it takes advantage of the new facility that
takes into account the whole length of the dictionary word when
computing scores, so words much longer than the input word will
see their score demoted accordingly.
Bug: 5384578
Change-Id: I326cd7c87c3080e7fa8729f78517f8ba13672a9b
Diffstat (limited to 'java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java index 1d5986ef9..9e030eb90 100644 --- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java +++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java @@ -28,11 +28,13 @@ import android.text.TextUtils; import com.android.inputmethod.compat.ArraysCompatUtils; import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.ProximityInfo; +import com.android.inputmethod.latin.BinaryDictionary; import com.android.inputmethod.latin.Dictionary; import com.android.inputmethod.latin.Dictionary.DataType; import com.android.inputmethod.latin.Dictionary.WordCallback; import com.android.inputmethod.latin.DictionaryCollection; import com.android.inputmethod.latin.DictionaryFactory; +import com.android.inputmethod.latin.Flag; import com.android.inputmethod.latin.LocaleUtils; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.SynchronouslyLoadedUserDictionary; @@ -65,6 +67,17 @@ public class AndroidSpellCheckerService extends SpellCheckerService { private final static SuggestionsInfo IN_DICT_EMPTY_SUGGESTIONS = new SuggestionsInfo(SuggestionsInfo.RESULT_ATTR_IN_THE_DICTIONARY, EMPTY_STRING_ARRAY); + private final static Flag[] USE_FULL_EDIT_DISTANCE_FLAG_ARRAY; + static { + // See BinaryDictionary.java for an explanation of these flags + // Specifially, ALL_CONFIG_FLAGS means that we want to consider all flags with the + // current dictionary configuration - for example, consider the UMLAUT flag + // so that it will be turned on for German dictionaries and off for others. + USE_FULL_EDIT_DISTANCE_FLAG_ARRAY = Arrays.copyOf(BinaryDictionary.ALL_CONFIG_FLAGS, + BinaryDictionary.ALL_CONFIG_FLAGS.length + 1); + USE_FULL_EDIT_DISTANCE_FLAG_ARRAY[BinaryDictionary.ALL_CONFIG_FLAGS.length] = + BinaryDictionary.FLAG_USE_FULL_EDIT_DISTANCE; + } private Map<String, DictionaryPool> mDictionaryPools = Collections.synchronizedMap(new TreeMap<String, DictionaryPool>()); private Map<String, Dictionary> mUserDictionaries = @@ -263,7 +276,8 @@ public class AndroidSpellCheckerService extends SpellCheckerService { final Resources resources = getResources(); final int fallbackResourceId = Utils.getMainDictionaryResourceId(resources); final DictionaryCollection dictionaryCollection = - DictionaryFactory.createDictionaryFromManager(this, locale, fallbackResourceId); + DictionaryFactory.createDictionaryFromManager(this, locale, fallbackResourceId, + USE_FULL_EDIT_DISTANCE_FLAG_ARRAY); final String localeStr = locale.toString(); Dictionary userDict = mUserDictionaries.get(localeStr); if (null == userDict) { |