aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-06-27 20:35:25 +0900
committerJean Chalard <jchalard@google.com>2012-06-28 19:10:13 +0900
commitb7cdafd78a7e97c70ceaa3349197eb012e69cc3f (patch)
treea151be05b70c7731219d6e1cbe7ee9b3087939fb /java/src
parent09b30ac95472195c37e5d32838dc3734c0310937 (diff)
downloadlatinime-b7cdafd78a7e97c70ceaa3349197eb012e69cc3f.tar.gz
latinime-b7cdafd78a7e97c70ceaa3349197eb012e69cc3f.tar.xz
latinime-b7cdafd78a7e97c70ceaa3349197eb012e69cc3f.zip
Don't pass everything to a function that needs only the head (A2)
Change-Id: Ic367836202ab8071c1a9a02eaf0651b0da947d51
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/AutoCorrection.java23
-rw-r--r--java/src/com/android/inputmethod/latin/Suggest.java4
2 files changed, 14 insertions, 13 deletions
diff --git a/java/src/com/android/inputmethod/latin/AutoCorrection.java b/java/src/com/android/inputmethod/latin/AutoCorrection.java
index 30b681651..b5934111f 100644
--- a/java/src/com/android/inputmethod/latin/AutoCorrection.java
+++ b/java/src/com/android/inputmethod/latin/AutoCorrection.java
@@ -34,17 +34,17 @@ public class AutoCorrection {
public static CharSequence computeAutoCorrectionWord(
final ConcurrentHashMap<String, Dictionary> dictionaries,
- final WordComposer wordComposer, final ArrayList<SuggestedWordInfo> suggestions,
+ final WordComposer wordComposer, SuggestedWordInfo suggestion,
final CharSequence consideredWord, final float autoCorrectionThreshold,
final CharSequence whitelistedWord) {
if (hasAutoCorrectionForWhitelistedWord(whitelistedWord)) {
return whitelistedWord;
} else if (hasAutoCorrectionForConsideredWord(
- dictionaries, wordComposer, suggestions, consideredWord)) {
+ dictionaries, wordComposer, suggestion, consideredWord)) {
return consideredWord;
- } else if (hasAutoCorrectionForBinaryDictionary(wordComposer, suggestions,
+ } else if (hasAutoCorrectionForBinaryDictionary(wordComposer, suggestion,
consideredWord, autoCorrectionThreshold)) {
- return suggestions.get(0).mWord;
+ return suggestion.mWord;
}
return null;
}
@@ -111,27 +111,26 @@ public class AutoCorrection {
private static boolean hasAutoCorrectionForConsideredWord(
final ConcurrentHashMap<String, Dictionary> dictionaries,
- final WordComposer wordComposer, final ArrayList<SuggestedWordInfo> suggestions,
+ final WordComposer wordComposer, final SuggestedWordInfo suggestion,
final CharSequence consideredWord) {
if (TextUtils.isEmpty(consideredWord)) return false;
- return wordComposer.size() > 1 && suggestions.size() > 0
+ return wordComposer.size() > 1 && null != suggestion
&& !allowsToBeAutoCorrected(dictionaries, consideredWord, false);
}
private static boolean hasAutoCorrectionForBinaryDictionary(WordComposer wordComposer,
- ArrayList<SuggestedWordInfo> suggestions,
+ SuggestedWordInfo suggestion,
CharSequence consideredWord, float autoCorrectionThreshold) {
- if (wordComposer.size() > 1 && suggestions.size() > 0) {
- final SuggestedWordInfo autoCorrectionSuggestion = suggestions.get(0);
+ if (wordComposer.size() > 1 && null != suggestion) {
//final int autoCorrectionSuggestionScore = sortedScores[0];
- final int autoCorrectionSuggestionScore = autoCorrectionSuggestion.mScore;
+ final int autoCorrectionSuggestionScore = suggestion.mScore;
// TODO: when the normalized score of the first suggestion is nearly equals to
// the normalized score of the second suggestion, behave less aggressive.
final float normalizedScore = BinaryDictionary.calcNormalizedScore(
- consideredWord.toString(), autoCorrectionSuggestion.mWord.toString(),
+ consideredWord.toString(), suggestion.mWord.toString(),
autoCorrectionSuggestionScore);
if (DBG) {
- Log.d(TAG, "Normalized " + consideredWord + "," + autoCorrectionSuggestion + ","
+ Log.d(TAG, "Normalized " + consideredWord + "," + suggestion + ","
+ autoCorrectionSuggestionScore + ", " + normalizedScore
+ "(" + autoCorrectionThreshold + ")");
}
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index 08a7b869d..baf24c8ae 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -249,6 +249,8 @@ public class Suggest {
transformedWordInfo.mSourceDict);
}
+ final SuggestedWordInfo bestSuggestion = suggestionsContainer.isEmpty()
+ ? null : suggestionsContainer.get(0);
final CharSequence whitelistedWord = capitalizeWord(isAllUpperCase,
isFirstCharCapitalized, mWhiteListDictionary.getWhitelistedWord(consideredWord));
@@ -256,7 +258,7 @@ public class Suggest {
if (isCorrectionEnabled) {
final CharSequence autoCorrection =
AutoCorrection.computeAutoCorrectionWord(mDictionaries, wordComposer,
- suggestionsContainer, consideredWord, mAutoCorrectionThreshold,
+ bestSuggestion, consideredWord, mAutoCorrectionThreshold,
whitelistedWord);
hasAutoCorrection = (null != autoCorrection);
} else {