aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/AutoCorrection.java19
-rw-r--r--java/src/com/android/inputmethod/latin/Suggest.java15
2 files changed, 18 insertions, 16 deletions
diff --git a/java/src/com/android/inputmethod/latin/AutoCorrection.java b/java/src/com/android/inputmethod/latin/AutoCorrection.java
index 9754d1517..851e287e5 100644
--- a/java/src/com/android/inputmethod/latin/AutoCorrection.java
+++ b/java/src/com/android/inputmethod/latin/AutoCorrection.java
@@ -32,14 +32,14 @@ public class AutoCorrection {
public static CharSequence computeAutoCorrectionWord(Map<String, Dictionary> dictionaries,
WordComposer wordComposer, ArrayList<CharSequence> suggestions, int[] sortedScores,
- CharSequence typedWord, double autoCorrectionThreshold, int correctionMode,
+ CharSequence typedWord, double autoCorrectionThreshold,
CharSequence whitelistedWord) {
if (hasAutoCorrectionForWhitelistedWord(whitelistedWord)) {
return whitelistedWord;
} else if (hasAutoCorrectionForTypedWord(
- dictionaries, wordComposer, suggestions, typedWord, correctionMode)) {
+ dictionaries, wordComposer, suggestions, typedWord)) {
return typedWord;
- } else if (hasAutoCorrectionForBinaryDictionary(wordComposer, suggestions, correctionMode,
+ } else if (hasAutoCorrectionForBinaryDictionary(wordComposer, suggestions,
sortedScores, typedWord, autoCorrectionThreshold)) {
return suggestions.get(0);
}
@@ -88,20 +88,17 @@ public class AutoCorrection {
}
private static boolean hasAutoCorrectionForTypedWord(Map<String, Dictionary> dictionaries,
- WordComposer wordComposer, ArrayList<CharSequence> suggestions, CharSequence typedWord,
- int correctionMode) {
+ WordComposer wordComposer, ArrayList<CharSequence> suggestions,
+ CharSequence typedWord) {
if (TextUtils.isEmpty(typedWord)) return false;
return wordComposer.size() > 1 && suggestions.size() > 0
- && !allowsToBeAutoCorrected(dictionaries, typedWord, false)
- && (correctionMode == Suggest.CORRECTION_FULL
- || correctionMode == Suggest.CORRECTION_FULL_BIGRAM);
+ && !allowsToBeAutoCorrected(dictionaries, typedWord, false);
}
private static boolean hasAutoCorrectionForBinaryDictionary(WordComposer wordComposer,
- ArrayList<CharSequence> suggestions, int correctionMode, int[] sortedScores,
+ ArrayList<CharSequence> suggestions, int[] sortedScores,
CharSequence typedWord, double autoCorrectionThreshold) {
- if (wordComposer.size() > 1 && (correctionMode == Suggest.CORRECTION_FULL
- || correctionMode == Suggest.CORRECTION_FULL_BIGRAM)
+ if (wordComposer.size() > 1
&& typedWord != null && suggestions.size() > 0 && sortedScores.length > 0) {
final CharSequence autoCorrectionSuggestion = suggestions.get(0);
final int autoCorrectionSuggestionScore = sortedScores[0];
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index a2131605d..a00cccab2 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -346,11 +346,16 @@ public class Suggest implements Dictionary.WordCallback {
CharSequence whitelistedWord = capitalizeWord(mIsAllUpperCase, mIsFirstCharCapitalized,
mWhiteListDictionary.getWhitelistedWord(consideredWordString));
- final CharSequence autoCorrection =
- AutoCorrection.computeAutoCorrectionWord(mUnigramDictionaries, wordComposer,
- mSuggestions, mScores, consideredWord, mAutoCorrectionThreshold, correctionMode,
- whitelistedWord);
- mHasAutoCorrection = (null != autoCorrection);
+ if (CORRECTION_FULL == correctionMode
+ || CORRECTION_FULL_BIGRAM == correctionMode) {
+ final CharSequence autoCorrection =
+ AutoCorrection.computeAutoCorrectionWord(mUnigramDictionaries, wordComposer,
+ mSuggestions, mScores, consideredWord, mAutoCorrectionThreshold,
+ whitelistedWord);
+ mHasAutoCorrection = (null != autoCorrection);
+ } else {
+ mHasAutoCorrection = false;
+ }
if (whitelistedWord != null) {
if (mTrailingSingleQuotesCount > 0) {