Treat apostrophe as single quote in spell checker
Bug: 6435348 Change-Id: Iaaac9042e7e6cb21a3f2243bc6e8e055cc24f74dmain
parent
8950ce6c44
commit
e58f3af8a7
|
@ -90,6 +90,8 @@ public class AndroidSpellCheckerService extends SpellCheckerService
|
||||||
|
|
||||||
public static final int SCRIPT_LATIN = 0;
|
public static final int SCRIPT_LATIN = 0;
|
||||||
public static final int SCRIPT_CYRILLIC = 1;
|
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;
|
private static final TreeMap<String, Integer> mLanguageToScript;
|
||||||
static {
|
static {
|
||||||
// List of the supported languages and their associated script. We won't check
|
// 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,
|
public SuggestionsInfo onGetSuggestions(final TextInfo textInfo,
|
||||||
final int suggestionsLimit) {
|
final int suggestionsLimit) {
|
||||||
try {
|
try {
|
||||||
final String text = textInfo.getText();
|
final String inText = textInfo.getText();
|
||||||
final SuggestionsParams cachedSuggestionsParams =
|
final SuggestionsParams cachedSuggestionsParams =
|
||||||
mSuggestionsCache.getSuggestionsFromCache(text);
|
mSuggestionsCache.getSuggestionsFromCache(inText);
|
||||||
if (cachedSuggestionsParams != null) {
|
if (cachedSuggestionsParams != null) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
Log.d(TAG, "Cache hit: " + text + ", " + cachedSuggestionsParams.mFlags);
|
Log.d(TAG, "Cache hit: " + inText + ", " + cachedSuggestionsParams.mFlags);
|
||||||
}
|
}
|
||||||
return new SuggestionsInfo(
|
return new SuggestionsInfo(
|
||||||
cachedSuggestionsParams.mFlags, cachedSuggestionsParams.mSuggestions);
|
cachedSuggestionsParams.mFlags, cachedSuggestionsParams.mSuggestions);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldFilterOut(text, mScript)) {
|
if (shouldFilterOut(inText, mScript)) {
|
||||||
DictAndProximity dictInfo = null;
|
DictAndProximity dictInfo = null;
|
||||||
try {
|
try {
|
||||||
dictInfo = mDictionaryPool.takeOrGetNull();
|
dictInfo = mDictionaryPool.takeOrGetNull();
|
||||||
if (null == dictInfo) return getNotInDictEmptySuggestions();
|
if (null == dictInfo) return getNotInDictEmptySuggestions();
|
||||||
return dictInfo.mDictionary.isValidWord(text) ? getInDictEmptySuggestions()
|
return dictInfo.mDictionary.isValidWord(inText) ?
|
||||||
: getNotInDictEmptySuggestions();
|
getInDictEmptySuggestions() : getNotInDictEmptySuggestions();
|
||||||
} finally {
|
} finally {
|
||||||
if (null != dictInfo) {
|
if (null != dictInfo) {
|
||||||
if (!mDictionaryPool.offer(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
|
// TODO: Don't gather suggestions if the limit is <= 0 unless necessary
|
||||||
final SuggestionsGatherer suggestionsGatherer = new SuggestionsGatherer(text,
|
final SuggestionsGatherer suggestionsGatherer = new SuggestionsGatherer(text,
|
||||||
|
|
Loading…
Reference in New Issue