aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorsatok <satok@google.com>2012-05-23 22:05:00 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-05-23 22:05:00 -0700
commit60b2d84d82ce8fd4a7bf4592d5229ee2436a675c (patch)
treea6fe0177780de3bc60500381a504cd37df659e38 /java
parent7d81f3187198b1589edab3c7883c3ee94855ed7e (diff)
parent1e1235feeb5454dc8dd76d68dbf634b35d2d20f2 (diff)
downloadlatinime-60b2d84d82ce8fd4a7bf4592d5229ee2436a675c.tar.gz
latinime-60b2d84d82ce8fd4a7bf4592d5229ee2436a675c.tar.xz
latinime-60b2d84d82ce8fd4a7bf4592d5229ee2436a675c.zip
am 1e1235fe: Merge "Support bigram suggestions in Android spell checker" into jb-dev
* commit '1e1235feeb5454dc8dd76d68dbf634b35d2d20f2': Support bigram suggestions in Android spell checker
Diffstat (limited to 'java')
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java29
1 files changed, 28 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 9807d2892..afd59c3f8 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
@@ -669,6 +669,28 @@ public class AndroidSpellCheckerService extends SpellCheckerService
return retval;
}
+ @Override
+ public SuggestionsInfo[] onGetSuggestionsMultiple(TextInfo[] textInfos,
+ int suggestionsLimit, boolean sequentialWords) {
+ final int length = textInfos.length;
+ final SuggestionsInfo[] retval = new SuggestionsInfo[length];
+ for (int i = 0; i < length; ++i) {
+ final String prevWord;
+ if (sequentialWords && i > 0) {
+ final String prevWordCandidate = textInfos[i - 1].getText();
+ // Note that an empty string would be used to indicate the initial word
+ // in the future.
+ prevWord = TextUtils.isEmpty(prevWordCandidate) ? null : prevWordCandidate;
+ } else {
+ prevWord = null;
+ }
+ retval[i] = onGetSuggestions(textInfos[i], prevWord, suggestionsLimit);
+ retval[i].setCookieAndSequence(
+ textInfos[i].getCookie(), textInfos[i].getSequence());
+ }
+ return retval;
+ }
+
// Note : this must be reentrant
/**
* Gets a list of suggestions for a specific string. This returns a list of possible
@@ -678,6 +700,11 @@ public class AndroidSpellCheckerService extends SpellCheckerService
@Override
public SuggestionsInfo onGetSuggestions(final TextInfo textInfo,
final int suggestionsLimit) {
+ return onGetSuggestions(textInfo, null, suggestionsLimit);
+ }
+
+ private SuggestionsInfo onGetSuggestions(
+ final TextInfo textInfo, final String prevWord, final int suggestionsLimit) {
try {
final String inText = textInfo.getText();
final SuggestionsParams cachedSuggestionsParams =
@@ -732,7 +759,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService
try {
dictInfo = mDictionaryPool.takeOrGetNull();
if (null == dictInfo) return getNotInDictEmptySuggestions();
- dictInfo.mDictionary.getWords(composer, null, suggestionsGatherer,
+ dictInfo.mDictionary.getWords(composer, prevWord, suggestionsGatherer,
dictInfo.mProximityInfo);
isInDict = dictInfo.mDictionary.isValidWord(text);
if (!isInDict && CAPITALIZE_NONE != capitalizeType) {