aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/inputmethod/latin/SuggestHelper.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2011-08-04 12:08:22 +0900
committerJean Chalard <jchalard@google.com>2011-08-04 19:46:21 +0900
commit043f7841985916717f4fa821fe3e423daf3ff2f5 (patch)
tree422cc67f9dd5d35a8c148e8e226343783a12ce84 /tests/src/com/android/inputmethod/latin/SuggestHelper.java
parent3889462439357fd76c0b82dfd52e1ca6e0bafd2d (diff)
downloadlatinime-043f7841985916717f4fa821fe3e423daf3ff2f5.tar.gz
latinime-043f7841985916717f4fa821fe3e423daf3ff2f5.tar.xz
latinime-043f7841985916717f4fa821fe3e423daf3ff2f5.zip
Create a way to pass the proximity info to the dictionary
This is a preparative change for inserting the spell checker. Change-Id: Ie441879cac4f67078ec27a95f1fcbbf3ef373df7
Diffstat (limited to 'tests/src/com/android/inputmethod/latin/SuggestHelper.java')
-rw-r--r--tests/src/com/android/inputmethod/latin/SuggestHelper.java25
1 files changed, 16 insertions, 9 deletions
diff --git a/tests/src/com/android/inputmethod/latin/SuggestHelper.java b/tests/src/com/android/inputmethod/latin/SuggestHelper.java
index 773674384..48fe81715 100644
--- a/tests/src/com/android/inputmethod/latin/SuggestHelper.java
+++ b/tests/src/com/android/inputmethod/latin/SuggestHelper.java
@@ -28,7 +28,7 @@ import java.io.File;
public class SuggestHelper {
protected final Suggest mSuggest;
- private final LatinKeyboard mKeyboard;
+ protected final LatinKeyboard mKeyboard;
private final KeyDetector mKeyDetector;
public SuggestHelper(Context context, int dictionaryId, KeyboardId keyboardId) {
@@ -94,19 +94,22 @@ public class SuggestHelper {
// TODO: This may be slow, but is OK for test so far.
public SuggestedWords getSuggestions(CharSequence typed) {
- return mSuggest.getSuggestions(null, createWordComposer(typed), null);
+ return mSuggest.getSuggestions(null, createWordComposer(typed), null,
+ mKeyboard.getProximityInfo());
}
public CharSequence getFirstSuggestion(CharSequence typed) {
WordComposer word = createWordComposer(typed);
- SuggestedWords suggestions = mSuggest.getSuggestions(null, word, null);
+ SuggestedWords suggestions = mSuggest.getSuggestions(null, word, null,
+ mKeyboard.getProximityInfo());
// Note that suggestions.getWord(0) is the word user typed.
return suggestions.size() > 1 ? suggestions.getWord(1) : null;
}
public CharSequence getAutoCorrection(CharSequence typed) {
WordComposer word = createWordComposer(typed);
- SuggestedWords suggestions = mSuggest.getSuggestions(null, word, null);
+ SuggestedWords suggestions = mSuggest.getSuggestions(null, word, null,
+ mKeyboard.getProximityInfo());
// Note that suggestions.getWord(0) is the word user typed.
return (suggestions.size() > 1 && mSuggest.hasAutoCorrection())
? suggestions.getWord(1) : null;
@@ -114,7 +117,8 @@ public class SuggestHelper {
public int getSuggestIndex(CharSequence typed, CharSequence expected) {
WordComposer word = createWordComposer(typed);
- SuggestedWords suggestions = mSuggest.getSuggestions(null, word, null);
+ SuggestedWords suggestions = mSuggest.getSuggestions(null, word, null,
+ mKeyboard.getProximityInfo());
// Note that suggestions.getWord(0) is the word user typed.
for (int i = 1; i < suggestions.size(); i++) {
if (TextUtils.equals(suggestions.getWord(i), expected))
@@ -126,21 +130,23 @@ public class SuggestHelper {
private void getBigramSuggestions(CharSequence previous, CharSequence typed) {
if (!TextUtils.isEmpty(previous) && (typed.length() > 1)) {
WordComposer firstChar = createWordComposer(Character.toString(typed.charAt(0)));
- mSuggest.getSuggestions(null, firstChar, previous);
+ mSuggest.getSuggestions(null, firstChar, previous, mKeyboard.getProximityInfo());
}
}
public CharSequence getBigramFirstSuggestion(CharSequence previous, CharSequence typed) {
WordComposer word = createWordComposer(typed);
getBigramSuggestions(previous, typed);
- SuggestedWords suggestions = mSuggest.getSuggestions(null, word, previous);
+ SuggestedWords suggestions = mSuggest.getSuggestions(null, word, previous,
+ mKeyboard.getProximityInfo());
return suggestions.size() > 1 ? suggestions.getWord(1) : null;
}
public CharSequence getBigramAutoCorrection(CharSequence previous, CharSequence typed) {
WordComposer word = createWordComposer(typed);
getBigramSuggestions(previous, typed);
- SuggestedWords suggestions = mSuggest.getSuggestions(null, word, previous);
+ SuggestedWords suggestions = mSuggest.getSuggestions(null, word, previous,
+ mKeyboard.getProximityInfo());
return (suggestions.size() > 1 && mSuggest.hasAutoCorrection())
? suggestions.getWord(1) : null;
}
@@ -149,7 +155,8 @@ public class SuggestHelper {
CharSequence expected) {
WordComposer word = createWordComposer(typed);
getBigramSuggestions(previous, typed);
- SuggestedWords suggestions = mSuggest.getSuggestions(null, word, previous);
+ SuggestedWords suggestions = mSuggest.getSuggestions(null, word, previous,
+ mKeyboard.getProximityInfo());
for (int i = 1; i < suggestions.size(); i++) {
if (TextUtils.equals(suggestions.getWord(i), expected))
return i;