Calculate the skip correction by one loop

Change-Id: Ie70829407cd58be2ffe75c7d649d86f62ee4df24
main
satok 2011-08-11 16:27:28 +09:00
parent 635f68e822
commit f3948c1eac
4 changed files with 18 additions and 14 deletions

View File

@ -54,11 +54,16 @@ void Correction::initCorrection(const ProximityInfo *pi, const int inputLength,
void Correction::initCorrectionState(
const int rootPos, const int childCount, const bool traverseAll) {
latinime::initCorrectionState(mCorrectionStates, rootPos, childCount, traverseAll);
// TODO: remove
mCorrectionStates[0].mSkipPos = mSkipPos;
}
void Correction::setCorrectionParams(const int skipPos, const int excessivePos,
const int transposedPos, const int spaceProximityPos, const int missingSpacePos) {
// TODO: remove
mSkipPos = skipPos;
// TODO: remove
mCorrectionStates[0].mSkipPos = skipPos;
mExcessivePos = excessivePos;
mTransposedPos = transposedPos;
mSpaceProximityPos = spaceProximityPos;
@ -111,6 +116,7 @@ bool Correction::initProcessState(const int outputIndex) {
mNeedsToTraverseAllNodes = mCorrectionStates[outputIndex].mNeedsToTraverseAllNodes;
mDiffs = mCorrectionStates[outputIndex].mDiffs;
mSkippedCount = mCorrectionStates[outputIndex].mSkippedCount;
mSkipPos = mCorrectionStates[outputIndex].mSkipPos;
mSkipping = false;
mMatching = false;
return true;
@ -158,6 +164,7 @@ void Correction::incrementOutputIndex() {
mCorrectionStates[mOutputIndex].mDiffs = mDiffs;
mCorrectionStates[mOutputIndex].mSkippedCount = mSkippedCount;
mCorrectionStates[mOutputIndex].mSkipping = mSkipping;
mCorrectionStates[mOutputIndex].mSkipPos = mSkipPos;
mCorrectionStates[mOutputIndex].mMatching = mMatching;
}
@ -195,6 +202,12 @@ Correction::CorrectionType Correction::processCharAndCalcState(
bool skip = false;
if (mSkipPos >= 0) {
if (mSkippedCount == 0 && mSkipPos < mOutputIndex) {
if (DEBUG_DICT) {
assert(mSkipPos == mOutputIndex - 1);
}
++mSkipPos;
}
skip = mSkipPos == mOutputIndex;
mSkipping = true;
}
@ -229,11 +242,6 @@ Correction::CorrectionType Correction::processCharAndCalcState(
}
}
// TODO: remove after allowing combination errors
if (skip) {
return UNRELATED;
}
mWord[mOutputIndex] = c;
// If inputIndex is greater than mInputLength, that means there is no
// proximity chars. So, we don't need to check proximity.

View File

@ -120,7 +120,6 @@ private:
int mMaxEditDistance;
int mMaxDepth;
int mInputLength;
int mSkipPos;
int mExcessivePos;
int mTransposedPos;
int mSpaceProximityPos;
@ -137,6 +136,7 @@ private:
int mDiffs;
int mMatchedCharCount;
int mSkippedCount;
int mSkipPos;
bool mNeedsToTraverseAllNodes;
bool mMatching;
bool mSkipping;

View File

@ -31,6 +31,7 @@ struct CorrectionState {
uint8_t mDiffs;
uint8_t mMatchedCount;
uint8_t mSkippedCount;
int8_t mSkipPos; // should be signed
bool mMatching;
bool mSkipping;
bool mNeedsToTraverseAllNodes;
@ -49,6 +50,7 @@ inline static void initCorrectionState(CorrectionState *state, const int rootPos
state->mMatching = false;
state->mSkipping = false;
state->mNeedsToTraverseAllNodes = traverseAll;
state->mSkipPos = -1;
}
} // namespace latinime

View File

@ -193,14 +193,8 @@ void UnigramDictionary::getWordSuggestions(ProximityInfo *proximityInfo,
PROF_START(2);
// Suggestion with missing character
if (SUGGEST_WORDS_WITH_MISSING_CHARACTER) {
for (int i = 0; i < codesSize; ++i) {
if (DEBUG_DICT) {
LOGI("--- Suggest missing characters %d", i);
}
getSuggestionCandidates(i, -1, -1);
}
}
LOGI("--- Suggest missing characters");
getSuggestionCandidates(0, -1, -1);
PROF_END(2);
PROF_START(3);