Make the autocorrection scheme more straightforward (A37)

Change-Id: I4833ca7e057b8c1f1f22390673cbca0d2433b1bd
This commit is contained in:
Jean Chalard 2012-06-28 19:45:24 +09:00
parent bd1d711488
commit cd288620ea
2 changed files with 7 additions and 6 deletions

View file

@ -295,7 +295,7 @@ public class Suggest {
// actual word, it says typedWordValid = false, which looks wrong. We should either // actual word, it says typedWordValid = false, which looks wrong. We should either
// rename the attribute or change the value. // rename the attribute or change the value.
!isPrediction && !allowsToBeAutoCorrected /* typedWordValid */, !isPrediction && !allowsToBeAutoCorrected /* typedWordValid */,
!isPrediction && hasAutoCorrection, /* hasAutoCorrectionCandidate */ !isPrediction && hasAutoCorrection && allowsToBeAutoCorrected, /* willAutoCorrect */
false /* isPunctuationSuggestions */, false /* isPunctuationSuggestions */,
false /* isObsoleteSuggestions */, false /* isObsoleteSuggestions */,
isPrediction); isPrediction);

View file

@ -28,7 +28,9 @@ public class SuggestedWords {
new ArrayList<SuggestedWordInfo>(0), false, false, false, false, false); new ArrayList<SuggestedWordInfo>(0), false, false, false, false, false);
public final boolean mTypedWordValid; public final boolean mTypedWordValid;
private final boolean mHasAutoCorrectionCandidate; // Note: this INCLUDES cases where the word will auto-correct to itself. A good definition
// of what this flag means would be "the top suggestion is strong enough to auto-correct",
// whether this exactly matches the user entry or not.
public final boolean mWillAutoCorrect; public final boolean mWillAutoCorrect;
public final boolean mIsPunctuationSuggestions; public final boolean mIsPunctuationSuggestions;
public final boolean mIsObsoleteSuggestions; public final boolean mIsObsoleteSuggestions;
@ -37,14 +39,13 @@ public class SuggestedWords {
public SuggestedWords(final ArrayList<SuggestedWordInfo> suggestedWordInfoList, public SuggestedWords(final ArrayList<SuggestedWordInfo> suggestedWordInfoList,
final boolean typedWordValid, final boolean typedWordValid,
final boolean hasAutoCorrectionCandidate, final boolean willAutoCorrect,
final boolean isPunctuationSuggestions, final boolean isPunctuationSuggestions,
final boolean isObsoleteSuggestions, final boolean isObsoleteSuggestions,
final boolean isPrediction) { final boolean isPrediction) {
mSuggestedWordInfoList = suggestedWordInfoList; mSuggestedWordInfoList = suggestedWordInfoList;
mTypedWordValid = typedWordValid; mTypedWordValid = typedWordValid;
mHasAutoCorrectionCandidate = hasAutoCorrectionCandidate; mWillAutoCorrect = willAutoCorrect;
mWillAutoCorrect = !mTypedWordValid && mHasAutoCorrectionCandidate;
mIsPunctuationSuggestions = isPunctuationSuggestions; mIsPunctuationSuggestions = isPunctuationSuggestions;
mIsObsoleteSuggestions = isObsoleteSuggestions; mIsObsoleteSuggestions = isObsoleteSuggestions;
mIsPrediction = isPrediction; mIsPrediction = isPrediction;
@ -75,7 +76,7 @@ public class SuggestedWords {
// Pretty-print method to help debug // Pretty-print method to help debug
return "SuggestedWords:" return "SuggestedWords:"
+ " mTypedWordValid=" + mTypedWordValid + " mTypedWordValid=" + mTypedWordValid
+ " mHasAutoCorrectionCandidate=" + mHasAutoCorrectionCandidate + " mWillAutoCorrect=" + mWillAutoCorrect
+ " mIsPunctuationSuggestions=" + mIsPunctuationSuggestions + " mIsPunctuationSuggestions=" + mIsPunctuationSuggestions
+ " words=" + Arrays.toString(mSuggestedWordInfoList.toArray()); + " words=" + Arrays.toString(mSuggestedWordInfoList.toArray());
} }