mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
refactor spell checker
Change-Id: Ie7bea23f2ac54f03572e77c31ba7cb3d5e8f8d2f
This commit is contained in:
parent
9d71a6c968
commit
a9dd74cf3f
@ -283,20 +283,6 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
|
|||||||
//suggestionsLimit);
|
//suggestionsLimit);
|
||||||
final SuggestionsGatherer suggestionsGatherer = mService.newSuggestionsGatherer(
|
final SuggestionsGatherer suggestionsGatherer = mService.newSuggestionsGatherer(
|
||||||
text, suggestionsLimit);
|
text, suggestionsLimit);
|
||||||
final WordComposer composer = new WordComposer();
|
|
||||||
final int length = text.length();
|
|
||||||
for (int i = 0; i < length; i = text.offsetByCodePoints(i, 1)) {
|
|
||||||
final int codePoint = text.codePointAt(i);
|
|
||||||
// The getXYForCodePointAndScript method returns (Y << 16) + X
|
|
||||||
final int xy = SpellCheckerProximityInfo.getXYForCodePointAndScript(
|
|
||||||
codePoint, mScript);
|
|
||||||
if (SpellCheckerProximityInfo.NOT_A_COORDINATE_PAIR == xy) {
|
|
||||||
composer.add(codePoint,
|
|
||||||
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
|
|
||||||
} else {
|
|
||||||
composer.add(codePoint, xy & 0xFFFF, xy >> 16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final int capitalizeType = StringUtils.getCapitalizationType(text);
|
final int capitalizeType = StringUtils.getCapitalizationType(text);
|
||||||
boolean isInDict = true;
|
boolean isInDict = true;
|
||||||
@ -306,6 +292,20 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
|
|||||||
if (!DictionaryPool.isAValidDictionary(dictInfo)) {
|
if (!DictionaryPool.isAValidDictionary(dictInfo)) {
|
||||||
return AndroidSpellCheckerService.getNotInDictEmptySuggestions();
|
return AndroidSpellCheckerService.getNotInDictEmptySuggestions();
|
||||||
}
|
}
|
||||||
|
final WordComposer composer = new WordComposer();
|
||||||
|
final int length = text.length();
|
||||||
|
for (int i = 0; i < length; i = text.offsetByCodePoints(i, 1)) {
|
||||||
|
final int codePoint = text.codePointAt(i);
|
||||||
|
// The getXYForCodePointAndScript method returns (Y << 16) + X
|
||||||
|
final int xy = SpellCheckerProximityInfo.getXYForCodePointAndScript(
|
||||||
|
codePoint, mScript);
|
||||||
|
if (SpellCheckerProximityInfo.NOT_A_COORDINATE_PAIR == xy) {
|
||||||
|
composer.add(codePoint,
|
||||||
|
Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE);
|
||||||
|
} else {
|
||||||
|
composer.add(codePoint, xy & 0xFFFF, xy >> 16);
|
||||||
|
}
|
||||||
|
}
|
||||||
// TODO: make a spell checker option to block offensive words or not
|
// TODO: make a spell checker option to block offensive words or not
|
||||||
final ArrayList<SuggestedWordInfo> suggestions =
|
final ArrayList<SuggestedWordInfo> suggestions =
|
||||||
dictInfo.mDictionary.getSuggestions(composer, prevWord,
|
dictInfo.mDictionary.getSuggestions(composer, prevWord,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user