Merge "Stop apply Completion for DicNodes without any proximity chars."

main
Keisuke Kuroyanagi 2014-03-20 09:48:20 +00:00 committed by Android (Google) Code Review
commit d6517e7cf5
3 changed files with 19 additions and 4 deletions

View File

@ -270,9 +270,10 @@ class DicNode {
bool hasMatchedOrProximityCodePoints() const {
// This DicNode does not have matched or proximity code points when all code points have
// been handled as edit corrections so far.
return mDicNodeState.mDicNodeStateScoring.getEditCorrectionCount()
< getNodeCodePointCount();
// been handled as edit corrections or completion so far.
const int editCorrectionCount = mDicNodeState.mDicNodeStateScoring.getEditCorrectionCount();
const int completionCount = mDicNodeState.mDicNodeStateScoring.getCompletionCount();
return (editCorrectionCount + completionCount) < getNodeCodePointCount();
}
bool isTotalInputSizeExceedingLimit() const {

View File

@ -31,7 +31,7 @@ class DicNodeStateScoring {
AK_FORCE_INLINE DicNodeStateScoring()
: mDoubleLetterLevel(NOT_A_DOUBLE_LETTER),
mDigraphIndex(DigraphUtils::NOT_A_DIGRAPH_INDEX),
mEditCorrectionCount(0), mProximityCorrectionCount(0),
mEditCorrectionCount(0), mProximityCorrectionCount(0), mCompletionCount(0),
mNormalizedCompoundDistance(0.0f), mSpatialDistance(0.0f), mLanguageDistance(0.0f),
mRawLength(0.0f), mContainedErrorTypes(ErrorTypeUtils::NOT_AN_ERROR),
mNormalizedCompoundDistanceAfterFirstWord(MAX_VALUE_FOR_WEIGHTING) {
@ -42,6 +42,7 @@ class DicNodeStateScoring {
void init() {
mEditCorrectionCount = 0;
mProximityCorrectionCount = 0;
mCompletionCount = 0;
mNormalizedCompoundDistance = 0.0f;
mSpatialDistance = 0.0f;
mLanguageDistance = 0.0f;
@ -55,6 +56,7 @@ class DicNodeStateScoring {
AK_FORCE_INLINE void init(const DicNodeStateScoring *const scoring) {
mEditCorrectionCount = scoring->mEditCorrectionCount;
mProximityCorrectionCount = scoring->mProximityCorrectionCount;
mCompletionCount = scoring->mCompletionCount;
mNormalizedCompoundDistance = scoring->mNormalizedCompoundDistance;
mSpatialDistance = scoring->mSpatialDistance;
mLanguageDistance = scoring->mLanguageDistance;
@ -77,6 +79,9 @@ class DicNodeStateScoring {
if (ErrorTypeUtils::isProximityCorrectionError(errorType)) {
++mProximityCorrectionCount;
}
if (ErrorTypeUtils::isCompletion(errorType)) {
++mCompletionCount;
}
}
// Saves the current normalized distance for space-aware gestures.
@ -129,6 +134,10 @@ class DicNodeStateScoring {
return mProximityCorrectionCount;
}
int16_t getCompletionCount() const {
return mCompletionCount;
}
float getRawLength() const {
return mRawLength;
}
@ -182,6 +191,7 @@ class DicNodeStateScoring {
int16_t mEditCorrectionCount;
int16_t mProximityCorrectionCount;
int16_t mCompletionCount;
float mNormalizedCompoundDistance;
float mSpatialDistance;

View File

@ -59,6 +59,10 @@ class ErrorTypeUtils {
return (errorType & PROXIMITY_CORRECTION) != 0;
}
static bool isCompletion(const ErrorType errorType) {
return (errorType & COMPLETION) != 0;
}
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(ErrorTypeUtils);