Calculate the skip correction by one loop
Change-Id: Ie70829407cd58be2ffe75c7d649d86f62ee4df24main
parent
635f68e822
commit
f3948c1eac
|
@ -54,11 +54,16 @@ void Correction::initCorrection(const ProximityInfo *pi, const int inputLength,
|
||||||
void Correction::initCorrectionState(
|
void Correction::initCorrectionState(
|
||||||
const int rootPos, const int childCount, const bool traverseAll) {
|
const int rootPos, const int childCount, const bool traverseAll) {
|
||||||
latinime::initCorrectionState(mCorrectionStates, rootPos, childCount, traverseAll);
|
latinime::initCorrectionState(mCorrectionStates, rootPos, childCount, traverseAll);
|
||||||
|
// TODO: remove
|
||||||
|
mCorrectionStates[0].mSkipPos = mSkipPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Correction::setCorrectionParams(const int skipPos, const int excessivePos,
|
void Correction::setCorrectionParams(const int skipPos, const int excessivePos,
|
||||||
const int transposedPos, const int spaceProximityPos, const int missingSpacePos) {
|
const int transposedPos, const int spaceProximityPos, const int missingSpacePos) {
|
||||||
|
// TODO: remove
|
||||||
mSkipPos = skipPos;
|
mSkipPos = skipPos;
|
||||||
|
// TODO: remove
|
||||||
|
mCorrectionStates[0].mSkipPos = skipPos;
|
||||||
mExcessivePos = excessivePos;
|
mExcessivePos = excessivePos;
|
||||||
mTransposedPos = transposedPos;
|
mTransposedPos = transposedPos;
|
||||||
mSpaceProximityPos = spaceProximityPos;
|
mSpaceProximityPos = spaceProximityPos;
|
||||||
|
@ -111,6 +116,7 @@ bool Correction::initProcessState(const int outputIndex) {
|
||||||
mNeedsToTraverseAllNodes = mCorrectionStates[outputIndex].mNeedsToTraverseAllNodes;
|
mNeedsToTraverseAllNodes = mCorrectionStates[outputIndex].mNeedsToTraverseAllNodes;
|
||||||
mDiffs = mCorrectionStates[outputIndex].mDiffs;
|
mDiffs = mCorrectionStates[outputIndex].mDiffs;
|
||||||
mSkippedCount = mCorrectionStates[outputIndex].mSkippedCount;
|
mSkippedCount = mCorrectionStates[outputIndex].mSkippedCount;
|
||||||
|
mSkipPos = mCorrectionStates[outputIndex].mSkipPos;
|
||||||
mSkipping = false;
|
mSkipping = false;
|
||||||
mMatching = false;
|
mMatching = false;
|
||||||
return true;
|
return true;
|
||||||
|
@ -158,6 +164,7 @@ void Correction::incrementOutputIndex() {
|
||||||
mCorrectionStates[mOutputIndex].mDiffs = mDiffs;
|
mCorrectionStates[mOutputIndex].mDiffs = mDiffs;
|
||||||
mCorrectionStates[mOutputIndex].mSkippedCount = mSkippedCount;
|
mCorrectionStates[mOutputIndex].mSkippedCount = mSkippedCount;
|
||||||
mCorrectionStates[mOutputIndex].mSkipping = mSkipping;
|
mCorrectionStates[mOutputIndex].mSkipping = mSkipping;
|
||||||
|
mCorrectionStates[mOutputIndex].mSkipPos = mSkipPos;
|
||||||
mCorrectionStates[mOutputIndex].mMatching = mMatching;
|
mCorrectionStates[mOutputIndex].mMatching = mMatching;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,6 +202,12 @@ Correction::CorrectionType Correction::processCharAndCalcState(
|
||||||
|
|
||||||
bool skip = false;
|
bool skip = false;
|
||||||
if (mSkipPos >= 0) {
|
if (mSkipPos >= 0) {
|
||||||
|
if (mSkippedCount == 0 && mSkipPos < mOutputIndex) {
|
||||||
|
if (DEBUG_DICT) {
|
||||||
|
assert(mSkipPos == mOutputIndex - 1);
|
||||||
|
}
|
||||||
|
++mSkipPos;
|
||||||
|
}
|
||||||
skip = mSkipPos == mOutputIndex;
|
skip = mSkipPos == mOutputIndex;
|
||||||
mSkipping = true;
|
mSkipping = true;
|
||||||
}
|
}
|
||||||
|
@ -229,11 +242,6 @@ Correction::CorrectionType Correction::processCharAndCalcState(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove after allowing combination errors
|
|
||||||
if (skip) {
|
|
||||||
return UNRELATED;
|
|
||||||
}
|
|
||||||
|
|
||||||
mWord[mOutputIndex] = c;
|
mWord[mOutputIndex] = c;
|
||||||
// If inputIndex is greater than mInputLength, that means there is no
|
// If inputIndex is greater than mInputLength, that means there is no
|
||||||
// proximity chars. So, we don't need to check proximity.
|
// proximity chars. So, we don't need to check proximity.
|
||||||
|
|
|
@ -120,7 +120,6 @@ private:
|
||||||
int mMaxEditDistance;
|
int mMaxEditDistance;
|
||||||
int mMaxDepth;
|
int mMaxDepth;
|
||||||
int mInputLength;
|
int mInputLength;
|
||||||
int mSkipPos;
|
|
||||||
int mExcessivePos;
|
int mExcessivePos;
|
||||||
int mTransposedPos;
|
int mTransposedPos;
|
||||||
int mSpaceProximityPos;
|
int mSpaceProximityPos;
|
||||||
|
@ -137,6 +136,7 @@ private:
|
||||||
int mDiffs;
|
int mDiffs;
|
||||||
int mMatchedCharCount;
|
int mMatchedCharCount;
|
||||||
int mSkippedCount;
|
int mSkippedCount;
|
||||||
|
int mSkipPos;
|
||||||
bool mNeedsToTraverseAllNodes;
|
bool mNeedsToTraverseAllNodes;
|
||||||
bool mMatching;
|
bool mMatching;
|
||||||
bool mSkipping;
|
bool mSkipping;
|
||||||
|
|
|
@ -31,6 +31,7 @@ struct CorrectionState {
|
||||||
uint8_t mDiffs;
|
uint8_t mDiffs;
|
||||||
uint8_t mMatchedCount;
|
uint8_t mMatchedCount;
|
||||||
uint8_t mSkippedCount;
|
uint8_t mSkippedCount;
|
||||||
|
int8_t mSkipPos; // should be signed
|
||||||
bool mMatching;
|
bool mMatching;
|
||||||
bool mSkipping;
|
bool mSkipping;
|
||||||
bool mNeedsToTraverseAllNodes;
|
bool mNeedsToTraverseAllNodes;
|
||||||
|
@ -49,6 +50,7 @@ inline static void initCorrectionState(CorrectionState *state, const int rootPos
|
||||||
state->mMatching = false;
|
state->mMatching = false;
|
||||||
state->mSkipping = false;
|
state->mSkipping = false;
|
||||||
state->mNeedsToTraverseAllNodes = traverseAll;
|
state->mNeedsToTraverseAllNodes = traverseAll;
|
||||||
|
state->mSkipPos = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace latinime
|
} // namespace latinime
|
||||||
|
|
|
@ -193,14 +193,8 @@ void UnigramDictionary::getWordSuggestions(ProximityInfo *proximityInfo,
|
||||||
|
|
||||||
PROF_START(2);
|
PROF_START(2);
|
||||||
// Suggestion with missing character
|
// Suggestion with missing character
|
||||||
if (SUGGEST_WORDS_WITH_MISSING_CHARACTER) {
|
LOGI("--- Suggest missing characters");
|
||||||
for (int i = 0; i < codesSize; ++i) {
|
getSuggestionCandidates(0, -1, -1);
|
||||||
if (DEBUG_DICT) {
|
|
||||||
LOGI("--- Suggest missing characters %d", i);
|
|
||||||
}
|
|
||||||
getSuggestionCandidates(i, -1, -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PROF_END(2);
|
PROF_END(2);
|
||||||
|
|
||||||
PROF_START(3);
|
PROF_START(3);
|
||||||
|
|
Loading…
Reference in New Issue