diff options
author | 2012-01-16 00:18:37 -0800 | |
---|---|---|
committer | 2012-01-16 00:18:37 -0800 | |
commit | 67e13976b78619ec7bc45b5377a9f5da2534cfd5 (patch) | |
tree | b75b4042868fc705a056854d4b33fa9bad533c74 /native/src/correction.cpp | |
parent | 9c283804efedd0e44f493e8dffd442156e76b69e (diff) | |
parent | 6ad15fcd158de5bec18f6529b961a55e7db9007f (diff) | |
download | latinime-67e13976b78619ec7bc45b5377a9f5da2534cfd5.tar.gz latinime-67e13976b78619ec7bc45b5377a9f5da2534cfd5.tar.xz latinime-67e13976b78619ec7bc45b5377a9f5da2534cfd5.zip |
Merge "Store suggestions for each input length for missing space algorithm etc."
Diffstat (limited to 'native/src/correction.cpp')
-rw-r--r-- | native/src/correction.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/native/src/correction.cpp b/native/src/correction.cpp index c40f94b3f..43ab3f59c 100644 --- a/native/src/correction.cpp +++ b/native/src/correction.cpp @@ -215,20 +215,10 @@ int Correction::goDownTree( } // TODO: remove -int Correction::getOutputIndex() { - return mOutputIndex; -} - -// TODO: remove int Correction::getInputIndex() { return mInputIndex; } -// TODO: remove -bool Correction::needsToTraverseAllNodes() { - return mNeedsToTraverseAllNodes; -} - void Correction::incrementInputIndex() { ++mInputIndex; } @@ -278,13 +268,12 @@ void Correction::addCharToCurrentWord(const int32_t c) { mWord, mOutputIndex + 1); } -// TODO: inline? Correction::CorrectionType Correction::processSkipChar( const int32_t c, const bool isTerminal, const bool inputIndexIncremented) { addCharToCurrentWord(c); - if (needsToTraverseAllNodes() && isTerminal) { - mTerminalInputIndex = mInputIndex - (inputIndexIncremented ? 1 : 0); - mTerminalOutputIndex = mOutputIndex; + mTerminalInputIndex = mInputIndex - (inputIndexIncremented ? 1 : 0); + mTerminalOutputIndex = mOutputIndex; + if (mNeedsToTraverseAllNodes && isTerminal) { incrementOutputIndex(); return TRAVERSE_ALL_ON_TERMINAL; } else { @@ -293,6 +282,13 @@ Correction::CorrectionType Correction::processSkipChar( } } +Correction::CorrectionType Correction::processUnrelatedCorrectionType() { + // Needs to set mTerminalInputIndex and mTerminalOutputIndex before returning any CorrectionType + mTerminalInputIndex = mInputIndex; + mTerminalOutputIndex = mOutputIndex; + return UNRELATED; +} + inline bool isEquivalentChar(ProximityInfo::ProximityType type) { return type == ProximityInfo::EQUIVALENT_CHAR; } @@ -301,7 +297,7 @@ Correction::CorrectionType Correction::processCharAndCalcState( const int32_t c, const bool isTerminal) { const int correctionCount = (mSkippedCount + mExcessiveCount + mTransposedCount); if (correctionCount > mMaxErrors) { - return UNRELATED; + return processUnrelatedCorrectionType(); } // TODO: Change the limit if we'll allow two or more corrections @@ -381,7 +377,7 @@ Correction::CorrectionType Correction::processCharAndCalcState( AKLOGI("UNRELATED(0): %d, %d, %d, %d, %c", mProximityCount, mSkippedCount, mTransposedCount, mExcessiveCount, c); } - return UNRELATED; + return processUnrelatedCorrectionType(); } } @@ -484,7 +480,7 @@ Correction::CorrectionType Correction::processCharAndCalcState( AKLOGI("UNRELATED(1): %d, %d, %d, %d, %c", mProximityCount, mSkippedCount, mTransposedCount, mExcessiveCount, c); } - return UNRELATED; + return processUnrelatedCorrectionType(); } } else if (secondTransposing) { // If inputIndex is greater than mInputLength, that means there is no @@ -539,6 +535,8 @@ Correction::CorrectionType Correction::processCharAndCalcState( } return ON_TERMINAL; } else { + mTerminalInputIndex = mInputIndex - 1; + mTerminalOutputIndex = mOutputIndex - 1; return NOT_ON_TERMINAL; } } |