diff options
author | 2011-08-03 23:27:32 +0900 | |
---|---|---|
committer | 2011-08-04 14:16:14 +0900 | |
commit | 4e4e74e6b659a069ca6e778f0ae7f9c7fa4343b7 (patch) | |
tree | 857d2238be03454b7cd09da8539910f25931781e /native/src/correction_state.cpp | |
parent | bb12dc455b46ef8872db8bbcff370151588f5b44 (diff) | |
download | latinime-4e4e74e6b659a069ca6e778f0ae7f9c7fa4343b7.tar.gz latinime-4e4e74e6b659a069ca6e778f0ae7f9c7fa4343b7.tar.xz latinime-4e4e74e6b659a069ca6e778f0ae7f9c7fa4343b7.zip |
Move the input index and output index to correction state
Change-Id: Idebdb59143f3367929df6a0475cefe941eb16d01
Diffstat (limited to 'native/src/correction_state.cpp')
-rw-r--r-- | native/src/correction_state.cpp | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/native/src/correction_state.cpp b/native/src/correction_state.cpp index add6cf673..b2c77b00d 100644 --- a/native/src/correction_state.cpp +++ b/native/src/correction_state.cpp @@ -58,32 +58,49 @@ int CorrectionState::getFreqForSplitTwoWords(const int firstFreq, const int seco return CorrectionState::RankingAlgorithm::calcFreqForSplitTwoWords(firstFreq, secondFreq, this); } -int CorrectionState::getFinalFreq(const int inputIndex, const int outputIndex, const int freq) { - const bool sameLength = (mExcessivePos == mInputLength - 1) ? (mInputLength == inputIndex + 2) - : (mInputLength == inputIndex + 1); - const int matchCount = mMatchedCharCount; +int CorrectionState::getFinalFreq(const unsigned short *word, const int freq) { + if (mProximityInfo->sameAsTyped(word, mOutputIndex + 1) || mOutputIndex < MIN_SUGGEST_DEPTH) { + return -1; + } + const bool sameLength = (mExcessivePos == mInputLength - 1) ? (mInputLength == mInputIndex + 2) + : (mInputLength == mInputIndex + 1); return CorrectionState::RankingAlgorithm::calculateFinalFreq( - inputIndex, outputIndex, matchCount, freq, sameLength, this); + mInputIndex, mOutputIndex, mMatchedCharCount, freq, sameLength, this); } -void CorrectionState::initDepth() { - mMatchedCharCount = 0; +void CorrectionState::initProcessState( + const int matchCount, const int inputIndex, const int outputIndex) { + mMatchedCharCount = matchCount; + mInputIndex = inputIndex; + mOutputIndex = outputIndex; +} + +void CorrectionState::getProcessState(int *matchedCount, int *inputIndex, int *outputIndex) { + *matchedCount = mMatchedCharCount; + *inputIndex = mInputIndex; + *outputIndex = mOutputIndex; } void CorrectionState::charMatched() { ++mMatchedCharCount; } -void CorrectionState::goUpTree(const int matchCount) { - mMatchedCharCount = matchCount; +// TODO: remove +int CorrectionState::getOutputIndex() { + return mOutputIndex; } -void CorrectionState::slideTree(const int matchCount) { - mMatchedCharCount = matchCount; +// TODO: remove +int CorrectionState::getInputIndex() { + return mInputIndex; } -void CorrectionState::goDownTree(int *matchedCount) { - *matchedCount = mMatchedCharCount; +void CorrectionState::incrementInputIndex() { + ++mInputIndex; +} + +void CorrectionState::incrementOutputIndex() { + ++mOutputIndex; } CorrectionState::~CorrectionState() { |