Loading java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java +10 −3 Original line number Diff line number Diff line Loading @@ -430,12 +430,19 @@ public class DictionaryFacilitatorForSuggest { public void getSuggestions(final WordComposer composer, final String prevWord, final ProximityInfo proximityInfo, final boolean blockOffensiveWords, final int[] additionalFeaturesOptions, final int sessionId, final Set<SuggestedWordInfo> suggestionSet) { final int sessionId, final Set<SuggestedWordInfo> suggestionSet, final ArrayList<SuggestedWordInfo> rawSuggestions) { for (final String key : mDictionaries.keySet()) { final Dictionary dictionary = mDictionaries.get(key); if (null == dictionary) continue; suggestionSet.addAll(dictionary.getSuggestionsWithSessionId(composer, prevWord, proximityInfo, blockOffensiveWords, additionalFeaturesOptions, sessionId)); final ArrayList<SuggestedWordInfo> dictionarySuggestions = dictionary.getSuggestionsWithSessionId(composer, prevWord, proximityInfo, blockOffensiveWords, additionalFeaturesOptions, sessionId); if (null == dictionarySuggestions) continue; suggestionSet.addAll(dictionarySuggestions); if (null != rawSuggestions) { rawSuggestions.addAll(dictionarySuggestions); } } } Loading java/src/com/android/inputmethod/latin/LatinIME.java +2 −2 Original line number Diff line number Diff line Loading @@ -998,7 +998,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen SuggestedWords.getFromApplicationSpecifiedCompletions( applicationSpecifiedCompletions); final SuggestedWords suggestedWords = new SuggestedWords( applicationSuggestedWords, applicationSuggestedWords, null /* rawSuggestions */, false /* typedWordValid */, false /* willAutoCorrect */, false /* isPunctuationSuggestions */, Loading Loading @@ -1418,7 +1418,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen ? SuggestedWords.EMPTY : previousSuggestedWords; final ArrayList<SuggestedWords.SuggestedWordInfo> typedWordAndPreviousSuggestions = SuggestedWords.getTypedWordAndPreviousSuggestions(typedWord, oldSuggestedWords); return new SuggestedWords(typedWordAndPreviousSuggestions, return new SuggestedWords(typedWordAndPreviousSuggestions, null /* rawSuggestions */, false /* typedWordValid */, false /* hasAutoCorrectionCandidate */, false /* isPunctuationSuggestions */, Loading java/src/com/android/inputmethod/latin/Suggest.java +18 −4 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ public final class Suggest { private static final int SUPPRESS_SUGGEST_THRESHOLD = -2000000000; private static final boolean DBG = LatinImeLogger.sDBG; private static final boolean INCLUDE_RAW_SUGGESTIONS = false; public final DictionaryFacilitatorForSuggest mDictionaryFacilitator; Loading Loading @@ -124,9 +125,15 @@ public final class Suggest { } else { wordComposerForLookup = wordComposer; } final ArrayList<SuggestedWordInfo> rawSuggestions; if (INCLUDE_RAW_SUGGESTIONS) { rawSuggestions = CollectionUtils.newArrayList(); } else { rawSuggestions = null; } mDictionaryFacilitator.getSuggestions(wordComposerForLookup, prevWordForBigram, proximityInfo, blockOffensiveWords, additionalFeaturesOptions, SESSION_TYPING, suggestionsSet); suggestionsSet, rawSuggestions); final String firstSuggestion; final String whitelistedWord; if (suggestionsSet.isEmpty()) { Loading Loading @@ -215,7 +222,7 @@ public final class Suggest { suggestionsList = suggestionsContainer; } callback.onGetSuggestedWords(new SuggestedWords(suggestionsList, callback.onGetSuggestedWords(new SuggestedWords(suggestionsList, rawSuggestions, // TODO: this first argument is lying. If this is a whitelisted word which is an // actual word, it says typedWordValid = false, which looks wrong. We should either // rename the attribute or change the value. Loading @@ -235,8 +242,15 @@ public final class Suggest { final OnGetSuggestedWordsCallback callback) { final BoundedTreeSet suggestionsSet = new BoundedTreeSet(sSuggestedWordInfoComparator, SuggestedWords.MAX_SUGGESTIONS); final ArrayList<SuggestedWordInfo> rawSuggestions; if (INCLUDE_RAW_SUGGESTIONS) { rawSuggestions = CollectionUtils.newArrayList(); } else { rawSuggestions = null; } mDictionaryFacilitator.getSuggestions(wordComposer, prevWordForBigram, proximityInfo, blockOffensiveWords, additionalFeaturesOptions, sessionId, suggestionsSet); blockOffensiveWords, additionalFeaturesOptions, sessionId, suggestionsSet, rawSuggestions); for (SuggestedWordInfo wordInfo : suggestionsSet) { LatinImeLogger.onAddSuggestedWord(wordInfo.mWord, wordInfo.mSourceDict.mDictType); } Loading Loading @@ -273,7 +287,7 @@ public final class Suggest { // In the batch input mode, the most relevant suggested word should act as a "typed word" // (typedWordValid=true), not as an "auto correct word" (willAutoCorrect=false). callback.onGetSuggestedWords(new SuggestedWords(suggestionsContainer, callback.onGetSuggestedWords(new SuggestedWords(suggestionsContainer, rawSuggestions, true /* typedWordValid */, false /* willAutoCorrect */, false /* isPunctuationSuggestions */, Loading java/src/com/android/inputmethod/latin/SuggestedWords.java +14 −8 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ public final class SuggestedWords { private static final ArrayList<SuggestedWordInfo> EMPTY_WORD_INFO_LIST = CollectionUtils.newArrayList(0); public static final SuggestedWords EMPTY = new SuggestedWords( EMPTY_WORD_INFO_LIST, false, false, false, false, false); EMPTY_WORD_INFO_LIST, null /* rawSuggestions */, false, false, false, false, false); public final String mTypedWord; public final boolean mTypedWordValid; Loading @@ -50,25 +50,29 @@ public final class SuggestedWords { public final boolean mIsPrediction; public final int mSequenceNumber; // Sequence number for auto-commit. private final ArrayList<SuggestedWordInfo> mSuggestedWordInfoList; public final ArrayList<SuggestedWordInfo> mRawSuggestions; public SuggestedWords(final ArrayList<SuggestedWordInfo> suggestedWordInfoList, final ArrayList<SuggestedWordInfo> rawSuggestions, final boolean typedWordValid, final boolean willAutoCorrect, final boolean isPunctuationSuggestions, final boolean isObsoleteSuggestions, final boolean isPrediction) { this(suggestedWordInfoList, typedWordValid, willAutoCorrect, isPunctuationSuggestions, isObsoleteSuggestions, isPrediction, NOT_A_SEQUENCE_NUMBER); this(suggestedWordInfoList, rawSuggestions, typedWordValid, willAutoCorrect, isPunctuationSuggestions, isObsoleteSuggestions, isPrediction, NOT_A_SEQUENCE_NUMBER); } public SuggestedWords(final ArrayList<SuggestedWordInfo> suggestedWordInfoList, final ArrayList<SuggestedWordInfo> rawSuggestions, final boolean typedWordValid, final boolean willAutoCorrect, final boolean isPunctuationSuggestions, final boolean isObsoleteSuggestions, final boolean isPrediction, final int sequenceNumber) { this(suggestedWordInfoList, this(suggestedWordInfoList, rawSuggestions, suggestedWordInfoList.isEmpty() ? null : suggestedWordInfoList.get(INDEX_OF_TYPED_WORD).mWord, typedWordValid, willAutoCorrect, isPunctuationSuggestions, Loading @@ -76,6 +80,7 @@ public final class SuggestedWords { } public SuggestedWords(final ArrayList<SuggestedWordInfo> suggestedWordInfoList, final ArrayList<SuggestedWordInfo> rawSuggestions, final String typedWord, final boolean typedWordValid, final boolean willAutoCorrect, Loading @@ -84,6 +89,7 @@ public final class SuggestedWords { final boolean isPrediction, final int sequenceNumber) { mSuggestedWordInfoList = suggestedWordInfoList; mRawSuggestions = rawSuggestions; mTypedWordValid = typedWordValid; mWillAutoCorrect = willAutoCorrect; mIsPunctuationSuggestions = isPunctuationSuggestions; Loading Loading @@ -306,9 +312,9 @@ public final class SuggestedWords { } // We should never autocorrect, so we say the typed word is valid. Also, in this case, // no auto-correction should take place hence willAutoCorrect = false. return new SuggestedWords(newSuggestions, typedWord, true /* typedWordValid */, false /* willAutoCorrect */, mIsPunctuationSuggestions, mIsObsoleteSuggestions, mIsPrediction, NOT_A_SEQUENCE_NUMBER); return new SuggestedWords(newSuggestions, null /* rawSuggestions */, typedWord, true /* typedWordValid */, false /* willAutoCorrect */, mIsPunctuationSuggestions, mIsObsoleteSuggestions, mIsPrediction, NOT_A_SEQUENCE_NUMBER); } // Creates a new SuggestedWordInfo from the currently suggested words that removes all but the Loading @@ -326,7 +332,7 @@ public final class SuggestedWords { info.mSourceDict, SuggestedWordInfo.NOT_AN_INDEX, SuggestedWordInfo.NOT_A_CONFIDENCE)); } return new SuggestedWords(newSuggestions, mTypedWordValid, return new SuggestedWords(newSuggestions, null /* rawSuggestions */, mTypedWordValid, mWillAutoCorrect, mIsPunctuationSuggestions, mIsObsoleteSuggestions, mIsPrediction); } Loading java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +2 −1 Original line number Diff line number Diff line Loading @@ -1332,7 +1332,8 @@ public final class InputLogic { } else { // We found suggestion spans in the word. We'll create the SuggestedWords out of // them, and make willAutoCorrect false. final SuggestedWords suggestedWords = new SuggestedWords(suggestions, typedWord, final SuggestedWords suggestedWords = new SuggestedWords(suggestions, null /* rawSuggestions */, typedWord, true /* typedWordValid */, false /* willAutoCorrect */, false /* isPunctuationSuggestions */, false /* isObsoleteSuggestions */, false /* isPrediction */, SuggestedWords.NOT_A_SEQUENCE_NUMBER); Loading Loading
java/src/com/android/inputmethod/latin/DictionaryFacilitatorForSuggest.java +10 −3 Original line number Diff line number Diff line Loading @@ -430,12 +430,19 @@ public class DictionaryFacilitatorForSuggest { public void getSuggestions(final WordComposer composer, final String prevWord, final ProximityInfo proximityInfo, final boolean blockOffensiveWords, final int[] additionalFeaturesOptions, final int sessionId, final Set<SuggestedWordInfo> suggestionSet) { final int sessionId, final Set<SuggestedWordInfo> suggestionSet, final ArrayList<SuggestedWordInfo> rawSuggestions) { for (final String key : mDictionaries.keySet()) { final Dictionary dictionary = mDictionaries.get(key); if (null == dictionary) continue; suggestionSet.addAll(dictionary.getSuggestionsWithSessionId(composer, prevWord, proximityInfo, blockOffensiveWords, additionalFeaturesOptions, sessionId)); final ArrayList<SuggestedWordInfo> dictionarySuggestions = dictionary.getSuggestionsWithSessionId(composer, prevWord, proximityInfo, blockOffensiveWords, additionalFeaturesOptions, sessionId); if (null == dictionarySuggestions) continue; suggestionSet.addAll(dictionarySuggestions); if (null != rawSuggestions) { rawSuggestions.addAll(dictionarySuggestions); } } } Loading
java/src/com/android/inputmethod/latin/LatinIME.java +2 −2 Original line number Diff line number Diff line Loading @@ -998,7 +998,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen SuggestedWords.getFromApplicationSpecifiedCompletions( applicationSpecifiedCompletions); final SuggestedWords suggestedWords = new SuggestedWords( applicationSuggestedWords, applicationSuggestedWords, null /* rawSuggestions */, false /* typedWordValid */, false /* willAutoCorrect */, false /* isPunctuationSuggestions */, Loading Loading @@ -1418,7 +1418,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen ? SuggestedWords.EMPTY : previousSuggestedWords; final ArrayList<SuggestedWords.SuggestedWordInfo> typedWordAndPreviousSuggestions = SuggestedWords.getTypedWordAndPreviousSuggestions(typedWord, oldSuggestedWords); return new SuggestedWords(typedWordAndPreviousSuggestions, return new SuggestedWords(typedWordAndPreviousSuggestions, null /* rawSuggestions */, false /* typedWordValid */, false /* hasAutoCorrectionCandidate */, false /* isPunctuationSuggestions */, Loading
java/src/com/android/inputmethod/latin/Suggest.java +18 −4 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ public final class Suggest { private static final int SUPPRESS_SUGGEST_THRESHOLD = -2000000000; private static final boolean DBG = LatinImeLogger.sDBG; private static final boolean INCLUDE_RAW_SUGGESTIONS = false; public final DictionaryFacilitatorForSuggest mDictionaryFacilitator; Loading Loading @@ -124,9 +125,15 @@ public final class Suggest { } else { wordComposerForLookup = wordComposer; } final ArrayList<SuggestedWordInfo> rawSuggestions; if (INCLUDE_RAW_SUGGESTIONS) { rawSuggestions = CollectionUtils.newArrayList(); } else { rawSuggestions = null; } mDictionaryFacilitator.getSuggestions(wordComposerForLookup, prevWordForBigram, proximityInfo, blockOffensiveWords, additionalFeaturesOptions, SESSION_TYPING, suggestionsSet); suggestionsSet, rawSuggestions); final String firstSuggestion; final String whitelistedWord; if (suggestionsSet.isEmpty()) { Loading Loading @@ -215,7 +222,7 @@ public final class Suggest { suggestionsList = suggestionsContainer; } callback.onGetSuggestedWords(new SuggestedWords(suggestionsList, callback.onGetSuggestedWords(new SuggestedWords(suggestionsList, rawSuggestions, // TODO: this first argument is lying. If this is a whitelisted word which is an // actual word, it says typedWordValid = false, which looks wrong. We should either // rename the attribute or change the value. Loading @@ -235,8 +242,15 @@ public final class Suggest { final OnGetSuggestedWordsCallback callback) { final BoundedTreeSet suggestionsSet = new BoundedTreeSet(sSuggestedWordInfoComparator, SuggestedWords.MAX_SUGGESTIONS); final ArrayList<SuggestedWordInfo> rawSuggestions; if (INCLUDE_RAW_SUGGESTIONS) { rawSuggestions = CollectionUtils.newArrayList(); } else { rawSuggestions = null; } mDictionaryFacilitator.getSuggestions(wordComposer, prevWordForBigram, proximityInfo, blockOffensiveWords, additionalFeaturesOptions, sessionId, suggestionsSet); blockOffensiveWords, additionalFeaturesOptions, sessionId, suggestionsSet, rawSuggestions); for (SuggestedWordInfo wordInfo : suggestionsSet) { LatinImeLogger.onAddSuggestedWord(wordInfo.mWord, wordInfo.mSourceDict.mDictType); } Loading Loading @@ -273,7 +287,7 @@ public final class Suggest { // In the batch input mode, the most relevant suggested word should act as a "typed word" // (typedWordValid=true), not as an "auto correct word" (willAutoCorrect=false). callback.onGetSuggestedWords(new SuggestedWords(suggestionsContainer, callback.onGetSuggestedWords(new SuggestedWords(suggestionsContainer, rawSuggestions, true /* typedWordValid */, false /* willAutoCorrect */, false /* isPunctuationSuggestions */, Loading
java/src/com/android/inputmethod/latin/SuggestedWords.java +14 −8 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ public final class SuggestedWords { private static final ArrayList<SuggestedWordInfo> EMPTY_WORD_INFO_LIST = CollectionUtils.newArrayList(0); public static final SuggestedWords EMPTY = new SuggestedWords( EMPTY_WORD_INFO_LIST, false, false, false, false, false); EMPTY_WORD_INFO_LIST, null /* rawSuggestions */, false, false, false, false, false); public final String mTypedWord; public final boolean mTypedWordValid; Loading @@ -50,25 +50,29 @@ public final class SuggestedWords { public final boolean mIsPrediction; public final int mSequenceNumber; // Sequence number for auto-commit. private final ArrayList<SuggestedWordInfo> mSuggestedWordInfoList; public final ArrayList<SuggestedWordInfo> mRawSuggestions; public SuggestedWords(final ArrayList<SuggestedWordInfo> suggestedWordInfoList, final ArrayList<SuggestedWordInfo> rawSuggestions, final boolean typedWordValid, final boolean willAutoCorrect, final boolean isPunctuationSuggestions, final boolean isObsoleteSuggestions, final boolean isPrediction) { this(suggestedWordInfoList, typedWordValid, willAutoCorrect, isPunctuationSuggestions, isObsoleteSuggestions, isPrediction, NOT_A_SEQUENCE_NUMBER); this(suggestedWordInfoList, rawSuggestions, typedWordValid, willAutoCorrect, isPunctuationSuggestions, isObsoleteSuggestions, isPrediction, NOT_A_SEQUENCE_NUMBER); } public SuggestedWords(final ArrayList<SuggestedWordInfo> suggestedWordInfoList, final ArrayList<SuggestedWordInfo> rawSuggestions, final boolean typedWordValid, final boolean willAutoCorrect, final boolean isPunctuationSuggestions, final boolean isObsoleteSuggestions, final boolean isPrediction, final int sequenceNumber) { this(suggestedWordInfoList, this(suggestedWordInfoList, rawSuggestions, suggestedWordInfoList.isEmpty() ? null : suggestedWordInfoList.get(INDEX_OF_TYPED_WORD).mWord, typedWordValid, willAutoCorrect, isPunctuationSuggestions, Loading @@ -76,6 +80,7 @@ public final class SuggestedWords { } public SuggestedWords(final ArrayList<SuggestedWordInfo> suggestedWordInfoList, final ArrayList<SuggestedWordInfo> rawSuggestions, final String typedWord, final boolean typedWordValid, final boolean willAutoCorrect, Loading @@ -84,6 +89,7 @@ public final class SuggestedWords { final boolean isPrediction, final int sequenceNumber) { mSuggestedWordInfoList = suggestedWordInfoList; mRawSuggestions = rawSuggestions; mTypedWordValid = typedWordValid; mWillAutoCorrect = willAutoCorrect; mIsPunctuationSuggestions = isPunctuationSuggestions; Loading Loading @@ -306,9 +312,9 @@ public final class SuggestedWords { } // We should never autocorrect, so we say the typed word is valid. Also, in this case, // no auto-correction should take place hence willAutoCorrect = false. return new SuggestedWords(newSuggestions, typedWord, true /* typedWordValid */, false /* willAutoCorrect */, mIsPunctuationSuggestions, mIsObsoleteSuggestions, mIsPrediction, NOT_A_SEQUENCE_NUMBER); return new SuggestedWords(newSuggestions, null /* rawSuggestions */, typedWord, true /* typedWordValid */, false /* willAutoCorrect */, mIsPunctuationSuggestions, mIsObsoleteSuggestions, mIsPrediction, NOT_A_SEQUENCE_NUMBER); } // Creates a new SuggestedWordInfo from the currently suggested words that removes all but the Loading @@ -326,7 +332,7 @@ public final class SuggestedWords { info.mSourceDict, SuggestedWordInfo.NOT_AN_INDEX, SuggestedWordInfo.NOT_A_CONFIDENCE)); } return new SuggestedWords(newSuggestions, mTypedWordValid, return new SuggestedWords(newSuggestions, null /* rawSuggestions */, mTypedWordValid, mWillAutoCorrect, mIsPunctuationSuggestions, mIsObsoleteSuggestions, mIsPrediction); } Loading
java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +2 −1 Original line number Diff line number Diff line Loading @@ -1332,7 +1332,8 @@ public final class InputLogic { } else { // We found suggestion spans in the word. We'll create the SuggestedWords out of // them, and make willAutoCorrect false. final SuggestedWords suggestedWords = new SuggestedWords(suggestions, typedWord, final SuggestedWords suggestedWords = new SuggestedWords(suggestions, null /* rawSuggestions */, typedWord, true /* typedWordValid */, false /* willAutoCorrect */, false /* isPunctuationSuggestions */, false /* isObsoleteSuggestions */, false /* isPrediction */, SuggestedWords.NOT_A_SEQUENCE_NUMBER); Loading