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

* commit 'd6517e7cf5bfa9d3f2c311924a3afb6e7f21b96f':
  Stop apply Completion for DicNodes without any proximity chars.
main
Keisuke Kuroyanagi 2014-03-20 02:51:41 -07:00 committed by Android Git Automerger
commit 0d00e56b54
3 changed files with 19 additions and 4 deletions

View File

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

View File

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

View File

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