diff options
author | 2012-05-07 06:28:55 -0700 | |
---|---|---|
committer | 2012-05-07 06:28:55 -0700 | |
commit | 725fff0511df20c5192e997475cd2c2c3dfaee3e (patch) | |
tree | 73563433e4947a3182db28540a11562bb1a8fb0a /java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java | |
parent | e70941cecb2c9f6085162ee4d7d441f848ed0e20 (diff) | |
parent | e58f3af8a7bf852c3b100de1bd85d95d13e0e15e (diff) | |
download | latinime-725fff0511df20c5192e997475cd2c2c3dfaee3e.tar.gz latinime-725fff0511df20c5192e997475cd2c2c3dfaee3e.tar.xz latinime-725fff0511df20c5192e997475cd2c2c3dfaee3e.zip |
am e58f3af8: Treat apostrophe as single quote in spell checker
* commit 'e58f3af8a7bf852c3b100de1bd85d95d13e0e15e':
Treat apostrophe as single quote in spell checker
Diffstat (limited to 'java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java index aa25faef5..f41645283 100644 --- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java +++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java @@ -90,6 +90,8 @@ public class AndroidSpellCheckerService extends SpellCheckerService public static final int SCRIPT_LATIN = 0; public static final int SCRIPT_CYRILLIC = 1; + private static final String SINGLE_QUOTE = "\u0027"; + private static final String APOSTROPHE = "\u2019"; private static final TreeMap<String, Integer> mLanguageToScript; static { // List of the supported languages and their associated script. We won't check @@ -574,24 +576,24 @@ public class AndroidSpellCheckerService extends SpellCheckerService public SuggestionsInfo onGetSuggestions(final TextInfo textInfo, final int suggestionsLimit) { try { - final String text = textInfo.getText(); + final String inText = textInfo.getText(); final SuggestionsParams cachedSuggestionsParams = - mSuggestionsCache.getSuggestionsFromCache(text); + mSuggestionsCache.getSuggestionsFromCache(inText); if (cachedSuggestionsParams != null) { if (DBG) { - Log.d(TAG, "Cache hit: " + text + ", " + cachedSuggestionsParams.mFlags); + Log.d(TAG, "Cache hit: " + inText + ", " + cachedSuggestionsParams.mFlags); } return new SuggestionsInfo( cachedSuggestionsParams.mFlags, cachedSuggestionsParams.mSuggestions); } - if (shouldFilterOut(text, mScript)) { + if (shouldFilterOut(inText, mScript)) { DictAndProximity dictInfo = null; try { dictInfo = mDictionaryPool.takeOrGetNull(); if (null == dictInfo) return getNotInDictEmptySuggestions(); - return dictInfo.mDictionary.isValidWord(text) ? getInDictEmptySuggestions() - : getNotInDictEmptySuggestions(); + return dictInfo.mDictionary.isValidWord(inText) ? + getInDictEmptySuggestions() : getNotInDictEmptySuggestions(); } finally { if (null != dictInfo) { if (!mDictionaryPool.offer(dictInfo)) { @@ -600,6 +602,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService } } } + final String text = inText.replaceAll(APOSTROPHE, SINGLE_QUOTE); // TODO: Don't gather suggestions if the limit is <= 0 unless necessary final SuggestionsGatherer suggestionsGatherer = new SuggestionsGatherer(text, |