From a49f61f8a73e64cb4db4f7ee5c0fe54fc40b367c Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Thu, 6 Feb 2014 15:51:04 +0900 Subject: Conditionally store the raw suggestions. Bug: 12913520 Change-Id: Ie15f97d90c142c51089280252b35b5ad1d226e19 --- .../src/com/android/inputmethod/latin/Suggest.java | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'java/src/com/android/inputmethod/latin/Suggest.java') diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index bb938a99e..5dbee0325 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -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; @@ -124,9 +125,15 @@ public final class Suggest { } else { wordComposerForLookup = wordComposer; } + final ArrayList 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()) { @@ -217,7 +224,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. @@ -237,8 +244,15 @@ public final class Suggest { final OnGetSuggestedWordsCallback callback) { final BoundedTreeSet suggestionsSet = new BoundedTreeSet(sSuggestedWordInfoComparator, SuggestedWords.MAX_SUGGESTIONS); + final ArrayList 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); } @@ -275,7 +289,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 */, -- cgit v1.2.3-83-g751a