From 673cebf9e97289b3b0cd343ff7193dff69684a48 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Thu, 29 Sep 2011 21:07:22 +0900 Subject: 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 --- .../latin/spellcheck/AndroidSpellCheckerService.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java') 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 mDictionaryPools = Collections.synchronizedMap(new TreeMap()); private Map 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) { -- cgit v1.2.3-83-g751a