Loading java/src/com/android/inputmethod/latin/BinaryDictionary.java +6 −8 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading java/src/com/android/inputmethod/latin/Dictionary.java +0 −22 Original line number Diff line number Diff line Loading @@ -64,28 +64,6 @@ public abstract class Dictionary { abstract public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer, 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. Loading java/src/com/android/inputmethod/latin/DictionaryCollection.java +0 −40 Original line number Diff line number Diff line Loading @@ -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) Loading java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java +0 −47 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); Loading java/src/com/android/inputmethod/latin/ExpandableDictionary.java +1 −24 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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(); Loading Loading
java/src/com/android/inputmethod/latin/BinaryDictionary.java +6 −8 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading
java/src/com/android/inputmethod/latin/Dictionary.java +0 −22 Original line number Diff line number Diff line Loading @@ -64,28 +64,6 @@ public abstract class Dictionary { abstract public ArrayList<SuggestedWordInfo> getSuggestions(final WordComposer composer, 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. Loading
java/src/com/android/inputmethod/latin/DictionaryCollection.java +0 −40 Original line number Diff line number Diff line Loading @@ -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) Loading
java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java +0 −47 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); Loading
java/src/com/android/inputmethod/latin/ExpandableDictionary.java +1 −24 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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(); Loading