aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-06-26 03:45:02 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-06-26 03:45:02 -0700
commit5d218bc029dae35133b3cec28b4df3197e490c3d (patch)
treeea402da2dfc2ef162542df9ab6074c99e32cbe82 /java/src
parent61c1002b6ba4e2efed9749973dcba89c93e39269 (diff)
parentbed514bd902d9736edcbfe03d37d8cced2bb03a3 (diff)
downloadlatinime-5d218bc029dae35133b3cec28b4df3197e490c3d.tar.gz
latinime-5d218bc029dae35133b3cec28b4df3197e490c3d.tar.xz
latinime-5d218bc029dae35133b3cec28b4df3197e490c3d.zip
Merge "Simplify a method call."
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/Suggest.java45
1 files changed, 21 insertions, 24 deletions
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index 0861a616c..30da08e57 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -222,7 +222,7 @@ public class Suggest {
mIsFirstCharCapitalized = !isPrediction && wordComposer.isFirstCharCapitalized();
mIsAllUpperCase = !isPrediction && wordComposer.isAllUpperCase();
mTrailingSingleQuotesCount = wordComposer.trailingSingleQuotesCount();
- final ArrayList<SuggestedWordInfo> suggestions =
+ final ArrayList<SuggestedWordInfo> suggestionsContainer =
new ArrayList<SuggestedWordInfo>(MAX_SUGGESTIONS);
final String typedWord = wordComposer.getTypedWord();
@@ -250,11 +250,9 @@ public class Suggest {
if (null != lowerPrevWord) {
localSuggestions.addAll(dictionary.getBigrams(wordComposer, lowerPrevWord));
}
- for (final SuggestedWordInfo suggestion : localSuggestions) {
- final String suggestionStr = suggestion.mWord.toString();
- addWord(suggestionStr, null,
- suggestion.mScore, dicTypeId, Dictionary.BIGRAM,
- suggestions, consideredWord);
+ for (final SuggestedWordInfo localSuggestion : localSuggestions) {
+ addWord(localSuggestion, dicTypeId, Dictionary.BIGRAM,
+ suggestionsContainer, consideredWord);
}
}
}
@@ -278,10 +276,8 @@ public class Suggest {
final ArrayList<SuggestedWordInfo> localSuggestions = dictionary.getWords(
wordComposerForLookup, prevWordForBigram, proximityInfo);
for (final SuggestedWordInfo suggestion : localSuggestions) {
- final String suggestionStr = suggestion.mWord.toString();
- addWord(suggestionStr, null,
- suggestion.mScore, dicTypeId, Dictionary.UNIGRAM,
- suggestions, consideredWord);
+ addWord(suggestion, dicTypeId, Dictionary.UNIGRAM,
+ suggestionsContainer, consideredWord);
}
}
}
@@ -293,7 +289,7 @@ public class Suggest {
if (isCorrectionEnabled) {
final CharSequence autoCorrection =
AutoCorrection.computeAutoCorrectionWord(mDictionaries, wordComposer,
- suggestions, consideredWord, mAutoCorrectionThreshold,
+ suggestionsContainer, consideredWord, mAutoCorrectionThreshold,
whitelistedWord);
hasAutoCorrection = (null != autoCorrection);
} else {
@@ -306,25 +302,25 @@ public class Suggest {
for (int i = mTrailingSingleQuotesCount - 1; i >= 0; --i) {
sb.appendCodePoint(Keyboard.CODE_SINGLE_QUOTE);
}
- suggestions.add(0, new SuggestedWordInfo(sb.toString(),
+ suggestionsContainer.add(0, new SuggestedWordInfo(sb.toString(),
SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_WHITELIST));
} else {
- suggestions.add(0, new SuggestedWordInfo(whitelistedWord,
+ suggestionsContainer.add(0, new SuggestedWordInfo(whitelistedWord,
SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_WHITELIST));
}
}
if (!isPrediction) {
- suggestions.add(0, new SuggestedWordInfo(typedWord, SuggestedWordInfo.MAX_SCORE,
- SuggestedWordInfo.KIND_TYPED));
+ suggestionsContainer.add(0, new SuggestedWordInfo(typedWord,
+ SuggestedWordInfo.MAX_SCORE, SuggestedWordInfo.KIND_TYPED));
}
- SuggestedWordInfo.removeDups(suggestions);
+ SuggestedWordInfo.removeDups(suggestionsContainer);
final ArrayList<SuggestedWordInfo> suggestionsList;
- if (DBG && !suggestions.isEmpty()) {
- suggestionsList = getSuggestionsInfoListWithDebugInfo(typedWord, suggestions);
+ if (DBG && !suggestionsContainer.isEmpty()) {
+ suggestionsList = getSuggestionsInfoListWithDebugInfo(typedWord, suggestionsContainer);
} else {
- suggestionsList = suggestions;
+ suggestionsList = suggestionsContainer;
}
// TODO: Change this scheme - a boolean is not enough. A whitelisted word may be "valid"
@@ -388,13 +384,14 @@ public class Suggest {
return suggestionsList;
}
- public boolean addWord(final String word, int[] indices,
- int score, final int dicTypeId, final int dataType,
+ public boolean addWord(final SuggestedWordInfo wordInfo,
+ final int dicTypeId, final int dataType,
final ArrayList<SuggestedWordInfo> suggestions, final String consideredWord) {
int dataTypeForLog = dataType;
final int prefMaxSuggestions = MAX_SUGGESTIONS;
- final int length = word.codePointCount(0, word.length());
+ final String word = wordInfo.mWord.toString();
+ final int score = wordInfo.mScore;
int pos = 0;
// Check if it's the same word, only caps are different
@@ -416,6 +413,7 @@ public class Suggest {
// Check the last one's score and bail
if (suggestions.size() >= prefMaxSuggestions
&& suggestions.get(prefMaxSuggestions - 1).mScore >= score) return true;
+ final int length = word.codePointCount(0, word.length());
while (pos < suggestions.size()) {
final int curScore = suggestions.get(pos).mScore;
if (curScore < score
@@ -440,8 +438,7 @@ public class Suggest {
for (int i = mTrailingSingleQuotesCount - 1; i >= 0; --i) {
sb.appendCodePoint(Keyboard.CODE_SINGLE_QUOTE);
}
- // TODO: figure out what type of suggestion this is
- suggestions.add(pos, new SuggestedWordInfo(sb, score, SuggestedWordInfo.KIND_CORRECTION));
+ suggestions.add(pos, new SuggestedWordInfo(sb, score, wordInfo.mKind));
if (suggestions.size() > prefMaxSuggestions) {
suggestions.remove(prefMaxSuggestions);
} else {