aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/Dictionary.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-07-09 16:34:49 +0900
committerJean Chalard <jchalard@google.com>2012-07-10 18:57:12 +0900
commit82009901eaa1fd0da95b25c900f8ff12fda9e679 (patch)
tree4bcaceffa6a14b6e96bf2bd32fa754d71658008f /java/src/com/android/inputmethod/latin/Dictionary.java
parent2a37fb9d30848aee42757546e8478cb7a9e45bc6 (diff)
downloadlatinime-82009901eaa1fd0da95b25c900f8ff12fda9e679.tar.gz
latinime-82009901eaa1fd0da95b25c900f8ff12fda9e679.tar.xz
latinime-82009901eaa1fd0da95b25c900f8ff12fda9e679.zip
Add a consolidated method to the Dictionary interface (A85)
Change-Id: I5d79021e69cc738e3013e31764ab0a59e15decdf
Diffstat (limited to 'java/src/com/android/inputmethod/latin/Dictionary.java')
-rw-r--r--java/src/com/android/inputmethod/latin/Dictionary.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/Dictionary.java b/java/src/com/android/inputmethod/latin/Dictionary.java
index 0835450c1..5229d14fa 100644
--- a/java/src/com/android/inputmethod/latin/Dictionary.java
+++ b/java/src/com/android/inputmethod/latin/Dictionary.java
@@ -16,6 +16,8 @@
package com.android.inputmethod.latin;
+import android.text.TextUtils;
+
import com.android.inputmethod.keyboard.ProximityInfo;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
@@ -50,6 +52,25 @@ public abstract class Dictionary {
}
/**
+ * Searches for suggestions for a given context. For the moment the context is only the
+ * previous word.
+ * @param composer the key sequence to match with coordinate info, as a WordComposer
+ * @param prevWord the previous word, or null if none
+ * @param proximityInfo the object for key proximity. May be ignored by some implementations.
+ * @return the list of suggestions (possibly null if none)
+ */
+ // TODO: pass more context than just the previous word, to enable better suggestions (n-gram
+ // and more)
+ public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer,
+ final CharSequence prevWord, final ProximityInfo proximityInfo) {
+ if (composer.size() <= 1) {
+ return TextUtils.isEmpty(prevWord) ? null : getBigrams(composer, prevWord);
+ } else {
+ return getWords(composer, prevWord, proximityInfo);
+ }
+ }
+
+ /**
* Searches for words in the dictionary that match the characters in the composer. Matched
* words are returned as an ArrayList.
* @param composer the key sequence to match with coordinate info, as a WordComposer