diff options
Diffstat (limited to 'java/src')
9 files changed, 16 insertions, 151 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index 03e286240..5c91a1077 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -109,15 +109,14 @@ public class BinaryDictionary extends Dictionary { 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); + return TextUtils.isEmpty(prevWord) ? null : getBigramsInternal(composer, prevWord); } else { - return getWords(composer, prevWord, proximityInfo); + return getWordsInternal(composer, prevWord, proximityInfo); } } - // TODO: rename this to getBigramsInternal, then move to native code - @Override - protected ArrayList<SuggestedWordInfo> getBigrams(final WordComposer codes, + // TODO: move to native code + private ArrayList<SuggestedWordInfo> getBigramsInternal(final WordComposer codes, final CharSequence previousWord) { if (mNativeDict == 0) return null; @@ -154,10 +153,9 @@ public class BinaryDictionary extends Dictionary { return suggestions; } - // TODO: rename this to getWordsInternal, then move to native code + // TODO: move to native code // proximityInfo and/or prevWordForBigrams may not be null. - @Override - protected ArrayList<SuggestedWordInfo> getWords(final WordComposer codes, + private ArrayList<SuggestedWordInfo> getWordsInternal(final WordComposer codes, final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo) { final int count = getSuggestions(codes, prevWordForBigrams, proximityInfo, mOutputChars, mScores, mSpaceIndices); diff --git a/java/src/com/android/inputmethod/latin/Dictionary.java b/java/src/com/android/inputmethod/latin/Dictionary.java index 38ef00da7..fd40aa6da 100644 --- a/java/src/com/android/inputmethod/latin/Dictionary.java +++ b/java/src/com/android/inputmethod/latin/Dictionary.java @@ -65,28 +65,6 @@ public abstract class Dictionary { final CharSequence prevWord, final ProximityInfo 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 - * @param prevWordForBigrams 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 - */ - // TODO: remove this - abstract protected ArrayList<SuggestedWordInfo> getWords(final WordComposer composer, - final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo); - - /** - * Searches for pairs in the bigram dictionary that matches the previous word. - * @param composer the key sequence to match - * @param previousWord the word before - * @return the list of suggestions - */ - // TODO: remove this - abstract protected ArrayList<SuggestedWordInfo> getBigrams(final WordComposer composer, - final CharSequence previousWord); - - /** * Checks if the given word occurs in the dictionary * @param word the word to search for. The search should be case-insensitive. * @return true if the word exists, false otherwise diff --git a/java/src/com/android/inputmethod/latin/DictionaryCollection.java b/java/src/com/android/inputmethod/latin/DictionaryCollection.java index 7c589ef17..88ac07d7a 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryCollection.java +++ b/java/src/com/android/inputmethod/latin/DictionaryCollection.java @@ -73,46 +73,6 @@ public class DictionaryCollection extends Dictionary { return suggestions; } - // TODO: remove this - @Override - protected ArrayList<SuggestedWordInfo> getWords(final WordComposer composer, - final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo) { - final CopyOnWriteArrayList<Dictionary> dictionaries = mDictionaries; - if (dictionaries.isEmpty()) return null; - // To avoid creating unnecessary objects, we get the list out of the first - // dictionary and add the rest to it if not null, hence the get(0) - ArrayList<SuggestedWordInfo> suggestions = dictionaries.get(0).getWords(composer, - prevWordForBigrams, proximityInfo); - if (null == suggestions) suggestions = new ArrayList<SuggestedWordInfo>(); - final int length = dictionaries.size(); - for (int i = 0; i < length; ++ i) { - final ArrayList<SuggestedWordInfo> sugg = dictionaries.get(i).getWords(composer, - prevWordForBigrams, proximityInfo); - if (null != sugg) suggestions.addAll(sugg); - } - return suggestions; - } - - // TODO: remove this - @Override - protected ArrayList<SuggestedWordInfo> getBigrams(final WordComposer composer, - final CharSequence previousWord) { - final CopyOnWriteArrayList<Dictionary> dictionaries = mDictionaries; - if (dictionaries.isEmpty()) return null; - // To avoid creating unnecessary objects, we get the list out of the first - // dictionary and add the rest to it if not null, hence the get(0) - ArrayList<SuggestedWordInfo> suggestions = dictionaries.get(0).getBigrams(composer, - previousWord); - if (null == suggestions) suggestions = new ArrayList<SuggestedWordInfo>(); - final int length = dictionaries.size(); - for (int i = 0; i < length; ++ i) { - final ArrayList<SuggestedWordInfo> sugg = - dictionaries.get(i).getBigrams(composer, previousWord); - if (null != sugg) suggestions.addAll(sugg); - } - return suggestions; - } - @Override public boolean isValidWord(CharSequence word) { for (int i = mDictionaries.size() - 1; i >= 0; --i) diff --git a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java index dd949f121..016530abb 100644 --- a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java @@ -16,7 +16,6 @@ package com.android.inputmethod.latin; import android.content.Context; import android.os.SystemClock; -import android.text.TextUtils; import android.util.Log; import com.android.inputmethod.keyboard.ProximityInfo; @@ -208,52 +207,6 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { return null; } - // TODO: remove this - @Override - protected ArrayList<SuggestedWordInfo> getWords(final WordComposer codes, - final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo) { - asyncReloadDictionaryIfRequired(); - return getWordsInner(codes, prevWordForBigrams, proximityInfo); - } - - protected final ArrayList<SuggestedWordInfo> getWordsInner(final WordComposer codes, - final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo) { - // Ensure that there are no concurrent calls to getWords. If there are, do nothing and - // return. - if (mLocalDictionaryController.tryLock()) { - try { - if (mBinaryDictionary != null) { - return mBinaryDictionary.getWords(codes, prevWordForBigrams, proximityInfo); - } - } finally { - mLocalDictionaryController.unlock(); - } - } - return null; - } - - // TODO: remove this - @Override - protected ArrayList<SuggestedWordInfo> getBigrams(final WordComposer codes, - final CharSequence previousWord) { - asyncReloadDictionaryIfRequired(); - return getBigramsInner(codes, previousWord); - } - - protected ArrayList<SuggestedWordInfo> getBigramsInner(final WordComposer codes, - final CharSequence previousWord) { - if (mLocalDictionaryController.tryLock()) { - try { - if (mBinaryDictionary != null) { - return mBinaryDictionary.getBigrams(codes, previousWord); - } - } finally { - mLocalDictionaryController.unlock(); - } - } - return null; - } - @Override public boolean isValidWord(final CharSequence word) { asyncReloadDictionaryIfRequired(); diff --git a/java/src/com/android/inputmethod/latin/ExpandableDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableDictionary.java index 6cd4f65cb..5d7995dc2 100644 --- a/java/src/com/android/inputmethod/latin/ExpandableDictionary.java +++ b/java/src/com/android/inputmethod/latin/ExpandableDictionary.java @@ -266,19 +266,6 @@ public class ExpandableDictionary extends Dictionary { } } - // TODO: remove this - @Override - protected ArrayList<SuggestedWordInfo> getWords(final WordComposer codes, - final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo) { - if (reloadDictionaryIfRequired()) return null; - if (codes.size() >= BinaryDictionary.MAX_WORD_LENGTH) { - return null; - } - final ArrayList<SuggestedWordInfo> suggestions = - getWordsInner(codes, prevWordForBigrams, proximityInfo); - return suggestions; - } - // This reloads the dictionary if required, and returns whether it's currently updating its // contents or not. // @VisibleForTesting @@ -290,17 +277,7 @@ public class ExpandableDictionary extends Dictionary { } } - // TODO: remove this - @Override - protected ArrayList<SuggestedWordInfo> getBigrams(final WordComposer codes, - final CharSequence previousWord) { - if (reloadDictionaryIfRequired()) return null; - final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<SuggestedWordInfo>(); - runBigramReverseLookUp(previousWord, suggestions); - return suggestions; - } - - protected final ArrayList<SuggestedWordInfo> getWordsInner(final WordComposer codes, + protected ArrayList<SuggestedWordInfo> getWordsInner(final WordComposer codes, final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo) { final ArrayList<SuggestedWordInfo> suggestions = new ArrayList<SuggestedWordInfo>(); mInputLength = codes.size(); diff --git a/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsBinaryDictionary.java b/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsBinaryDictionary.java index 59bd249e7..bdd988df2 100644 --- a/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/SynchronouslyLoadedContactsBinaryDictionary.java @@ -32,10 +32,10 @@ public class SynchronouslyLoadedContactsBinaryDictionary extends ContactsBinaryD } @Override - protected synchronized ArrayList<SuggestedWordInfo> getWords(final WordComposer codes, + public synchronized ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer codes, final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo) { syncReloadDictionaryIfRequired(); - return getWordsInner(codes, prevWordForBigrams, proximityInfo); + return super.getSuggestions(codes, prevWordForBigrams, proximityInfo); } @Override diff --git a/java/src/com/android/inputmethod/latin/SynchronouslyLoadedUserBinaryDictionary.java b/java/src/com/android/inputmethod/latin/SynchronouslyLoadedUserBinaryDictionary.java index 7abc251be..b8cfddd4e 100644 --- a/java/src/com/android/inputmethod/latin/SynchronouslyLoadedUserBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/SynchronouslyLoadedUserBinaryDictionary.java @@ -35,10 +35,10 @@ public class SynchronouslyLoadedUserBinaryDictionary extends UserBinaryDictionar } @Override - protected synchronized ArrayList<SuggestedWordInfo> getWords(final WordComposer codes, + public synchronized ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer codes, final CharSequence prevWordForBigrams, final ProximityInfo proximityInfo) { syncReloadDictionaryIfRequired(); - return getWordsInner(codes, prevWordForBigrams, proximityInfo); + return super.getSuggestions(codes, prevWordForBigrams, proximityInfo); } @Override diff --git a/java/src/com/android/inputmethod/latin/UserHistoryDictionary.java b/java/src/com/android/inputmethod/latin/UserHistoryDictionary.java index e26349172..3bb670c9a 100644 --- a/java/src/com/android/inputmethod/latin/UserHistoryDictionary.java +++ b/java/src/com/android/inputmethod/latin/UserHistoryDictionary.java @@ -161,10 +161,10 @@ public class UserHistoryDictionary extends ExpandableDictionary { } @Override - protected ArrayList<SuggestedWordInfo> getWords(final WordComposer composer, + protected ArrayList<SuggestedWordInfo> getWordsInner(final WordComposer composer, final CharSequence prevWord, final ProximityInfo proximityInfo) { - // User history unigrams are not used at this moment. Implement this method to make them - // useful. + // Inhibit suggestions (not predictions) for user history for now. Removing this method + // is enough to use it through the standard ExpandableDictionary way. return null; } diff --git a/java/src/com/android/inputmethod/latin/WhitelistDictionary.java b/java/src/com/android/inputmethod/latin/WhitelistDictionary.java index be2c80e0e..14476dcf0 100644 --- a/java/src/com/android/inputmethod/latin/WhitelistDictionary.java +++ b/java/src/com/android/inputmethod/latin/WhitelistDictionary.java @@ -92,10 +92,9 @@ public class WhitelistDictionary extends ExpandableDictionary { } @Override - protected ArrayList<SuggestedWordInfo> getWords(final WordComposer composer, + public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer, final CharSequence prevWord, final ProximityInfo proximityInfo) { - // Whitelist does not supply suggestions (actually it should not even implement the - // Dictionary interface, as it responds to none of it, but it does for legacy reasons) + // Whitelist does not supply any suggestions or predictions. return null; } |