aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsatok <satok@google.com>2011-10-06 12:24:59 +0900
committersatok <satok@google.com>2011-10-07 00:23:26 +0900
commit57834c20a5f2e4c944e09eb4fcddb440bbd46e20 (patch)
treec26f54b46075de62e680b14c772fbfd84e4246ac
parent3458d61807a03ed7fb8571488ee0fcbff39e07f8 (diff)
downloadlatinime-57834c20a5f2e4c944e09eb4fcddb440bbd46e20.tar.gz
latinime-57834c20a5f2e4c944e09eb4fcddb440bbd46e20.tar.xz
latinime-57834c20a5f2e4c944e09eb4fcddb440bbd46e20.zip
Fix a bug of the conversion of the correction algorithm
Bug: 5414829 +1 25 -1 17 +2 0 -2 0 +3 0 -3 0 +4 15 -4 9 +5 2 -5 9 +6 13 -6 4 +7 3 -7 19 Change-Id: Ie99db961051320ee31d31476ea7c25b1d837c484
-rw-r--r--native/src/correction.cpp39
1 files changed, 31 insertions, 8 deletions
diff --git a/native/src/correction.cpp b/native/src/correction.cpp
index d1e866d9d..a08a21bd2 100644
--- a/native/src/correction.cpp
+++ b/native/src/correction.cpp
@@ -299,23 +299,41 @@ Correction::CorrectionType Correction::processCharAndCalcState(
// TODO: Change the limit if we'll allow two or more proximity chars with corrections
const bool checkProximityChars = noCorrectionsHappenedSoFar || mProximityCount == 0;
- const ProximityInfo::ProximityType matchedProximityCharId = secondTransposing
+ ProximityInfo::ProximityType matchedProximityCharId = secondTransposing
? ProximityInfo::EQUIVALENT_CHAR
: mProximityInfo->getMatchedProximityId(mInputIndex, c, checkProximityChars);
if (ProximityInfo::UNRELATED_CHAR == matchedProximityCharId) {
- // TODO: Optimize
- // As the current char turned out to be an unrelated char,
- // we will try other correction-types. Please note that mCorrectionStates[mOutputIndex]
- // here refers to the previous state.
- if (canTryCorrection && mCorrectionStates[mOutputIndex].mProximityMatching
+ if (canTryCorrection && mOutputIndex > 0
+ && mCorrectionStates[mOutputIndex].mProximityMatching
&& mCorrectionStates[mOutputIndex].mExceeding
&& isEquivalentChar(mProximityInfo->getMatchedProximityId(
- mInputIndex, mWord[mOutputIndex], false))) {
+ mInputIndex, mWord[mOutputIndex - 1], false))) {
+ if (DEBUG_CORRECTION) {
+ LOGI("CONVERSION p->e %c", mWord[mOutputIndex - 1]);
+ }
// Conversion p->e
+ // Example:
+ // wearth -> earth
+ // px -> (E)mmmmm
++mExcessiveCount;
--mProximityCount;
- } else if (mInputIndex < mInputLength - 1 && mOutputIndex > 0 && mTransposedCount > 0
+ mExcessivePos = mOutputIndex - 1;
+ ++mInputIndex;
+ // Here, we are doing something equivalent to matchedProximityCharId,
+ // but we already know that "excessive char correction" just happened
+ // so that we just need to check "mProximityCount == 0".
+ matchedProximityCharId =
+ mProximityInfo->getMatchedProximityId(mInputIndex, c, mProximityCount == 0);
+ }
+ }
+
+ if (ProximityInfo::UNRELATED_CHAR == matchedProximityCharId) {
+ // TODO: Optimize
+ // As the current char turned out to be an unrelated char,
+ // we will try other correction-types. Please note that mCorrectionStates[mOutputIndex]
+ // here refers to the previous state.
+ if (mInputIndex < mInputLength - 1 && mOutputIndex > 0 && mTransposedCount > 0
&& !mCorrectionStates[mOutputIndex].mTransposing
&& mCorrectionStates[mOutputIndex - 1].mTransposing
&& isEquivalentChar(mProximityInfo->getMatchedProximityId(
@@ -425,6 +443,11 @@ Correction::CorrectionType Correction::processCharAndCalcState(
|| isSameAsUserTypedLength) && isTerminal) {
mTerminalInputIndex = mInputIndex - 1;
mTerminalOutputIndex = mOutputIndex - 1;
+ if (DEBUG_CORRECTION) {
+ DUMP_WORD(mWord, mOutputIndex);
+ LOGI("ONTERMINAL(1): %d, %d, %d, %d, %c", mProximityCount, mSkippedCount,
+ mTransposedCount, mExcessiveCount, c);
+ }
return ON_TERMINAL;
} else {
return NOT_ON_TERMINAL;