Merge "Rename a parameter (B6)"

This commit is contained in:
Jean Chalard 2012-03-08 22:23:33 -08:00 committed by Android (Google) Code Review
commit 2d82757fc6

View file

@ -32,15 +32,15 @@ public class AutoCorrection {
public static CharSequence computeAutoCorrectionWord(Map<String, Dictionary> dictionaries, public static CharSequence computeAutoCorrectionWord(Map<String, Dictionary> dictionaries,
WordComposer wordComposer, ArrayList<CharSequence> suggestions, int[] sortedScores, WordComposer wordComposer, ArrayList<CharSequence> suggestions, int[] sortedScores,
CharSequence typedWord, double autoCorrectionThreshold, CharSequence consideredWord, double autoCorrectionThreshold,
CharSequence whitelistedWord) { CharSequence whitelistedWord) {
if (hasAutoCorrectionForWhitelistedWord(whitelistedWord)) { if (hasAutoCorrectionForWhitelistedWord(whitelistedWord)) {
return whitelistedWord; return whitelistedWord;
} else if (hasAutoCorrectionForTypedWord( } else if (hasAutoCorrectionForConsideredWord(
dictionaries, wordComposer, suggestions, typedWord)) { dictionaries, wordComposer, suggestions, consideredWord)) {
return typedWord; return consideredWord;
} else if (hasAutoCorrectionForBinaryDictionary(wordComposer, suggestions, } else if (hasAutoCorrectionForBinaryDictionary(wordComposer, suggestions,
sortedScores, typedWord, autoCorrectionThreshold)) { sortedScores, consideredWord, autoCorrectionThreshold)) {
return suggestions.get(0); return suggestions.get(0);
} }
return null; return null;
@ -87,28 +87,28 @@ public class AutoCorrection {
return whiteListedWord != null; return whiteListedWord != null;
} }
private static boolean hasAutoCorrectionForTypedWord(Map<String, Dictionary> dictionaries, private static boolean hasAutoCorrectionForConsideredWord(Map<String, Dictionary> dictionaries,
WordComposer wordComposer, ArrayList<CharSequence> suggestions, WordComposer wordComposer, ArrayList<CharSequence> suggestions,
CharSequence typedWord) { CharSequence consideredWord) {
if (TextUtils.isEmpty(typedWord)) return false; if (TextUtils.isEmpty(consideredWord)) return false;
return wordComposer.size() > 1 && suggestions.size() > 0 return wordComposer.size() > 1 && suggestions.size() > 0
&& !allowsToBeAutoCorrected(dictionaries, typedWord, false); && !allowsToBeAutoCorrected(dictionaries, consideredWord, false);
} }
private static boolean hasAutoCorrectionForBinaryDictionary(WordComposer wordComposer, private static boolean hasAutoCorrectionForBinaryDictionary(WordComposer wordComposer,
ArrayList<CharSequence> suggestions, int[] sortedScores, ArrayList<CharSequence> suggestions, int[] sortedScores,
CharSequence typedWord, double autoCorrectionThreshold) { CharSequence consideredWord, double autoCorrectionThreshold) {
if (wordComposer.size() > 1 if (wordComposer.size() > 1
&& typedWord != null && suggestions.size() > 0 && sortedScores.length > 0) { && consideredWord != null && suggestions.size() > 0 && sortedScores.length > 0) {
final CharSequence autoCorrectionSuggestion = suggestions.get(0); final CharSequence autoCorrectionSuggestion = suggestions.get(0);
final int autoCorrectionSuggestionScore = sortedScores[0]; final int autoCorrectionSuggestionScore = sortedScores[0];
// TODO: when the normalized score of the first suggestion is nearly equals to // TODO: when the normalized score of the first suggestion is nearly equals to
// the normalized score of the second suggestion, behave less aggressive. // the normalized score of the second suggestion, behave less aggressive.
final double normalizedScore = BinaryDictionary.calcNormalizedScore( final double normalizedScore = BinaryDictionary.calcNormalizedScore(
typedWord.toString(), autoCorrectionSuggestion.toString(), consideredWord.toString(), autoCorrectionSuggestion.toString(),
autoCorrectionSuggestionScore); autoCorrectionSuggestionScore);
if (DBG) { if (DBG) {
Log.d(TAG, "Normalized " + typedWord + "," + autoCorrectionSuggestion + "," Log.d(TAG, "Normalized " + consideredWord + "," + autoCorrectionSuggestion + ","
+ autoCorrectionSuggestionScore + ", " + normalizedScore + autoCorrectionSuggestionScore + ", " + normalizedScore
+ "(" + autoCorrectionThreshold + ")"); + "(" + autoCorrectionThreshold + ")");
} }