Loading native/src/correction.cpp +54 −34 Original line number Diff line number Diff line Loading @@ -745,13 +745,13 @@ int Correction::RankingAlgorithm::calculateFinalFreq(const int inputIndex, const // Score calibration by touch coordinates is being done only for pure-fat finger typing error // cases. // TODO: Remove this constraint. if (performTouchPositionCorrection) { for (int i = 0; i < outputLength; ++i) { const int squaredDistance = correction->mDistances[i]; if (i < adjustedProximityMatchedCount) { multiplyIntCapped(typedLetterMultiplier, &finalFreq); } if (performTouchPositionCorrection && squaredDistance >= 0) { if (squaredDistance >= 0) { // Promote or demote the score according to the distance from the sweet spot static const float A = ZERO_DISTANCE_PROMOTION_RATE / 100.0f; static const float B = 1.0f; Loading @@ -773,15 +773,35 @@ int Correction::RankingAlgorithm::calculateFinalFreq(const int inputIndex, const // . // 0 R1 R2 . multiplyRate((int)(factor * 100), &finalFreq); } else if (performTouchPositionCorrection && squaredDistance == PROXIMITY_CHAR_WITHOUT_DISTANCE_INFO) { } else if (squaredDistance == PROXIMITY_CHAR_WITHOUT_DISTANCE_INFO) { multiplyRate(WORDS_WITH_PROXIMITY_CHARACTER_DEMOTION_RATE, &finalFreq); } else if (squaredDistance == ADDITIONAL_PROXIMITY_CHAR_DISTANCE_INFO) { multiplyRate(WORDS_WITH_ADDITIONAL_PROXIMITY_CHARACTER_DEMOTION_RATE, &finalFreq); } else if (i < adjustedProximityMatchedCount) { } } } else { // Demote additional proximity characters int additionalProximityCount = 0; for (int i = 0; i < outputLength; ++i) { const int squaredDistance = correction->mDistances[i]; if (squaredDistance == ADDITIONAL_PROXIMITY_CHAR_DISTANCE_INFO) { ++additionalProximityCount; } } // Promotion for a word with proximity characters for (int i = 0; i < adjustedProximityMatchedCount; ++i) { // A word with proximity corrections if (DEBUG_DICT_FULL) { AKLOGI("Found a proximity correction."); } multiplyIntCapped(typedLetterMultiplier, &finalFreq); if (i < additionalProximityCount) { multiplyRate(WORDS_WITH_ADDITIONAL_PROXIMITY_CHARACTER_DEMOTION_RATE, &finalFreq); } else { multiplyRate(WORDS_WITH_PROXIMITY_CHARACTER_DEMOTION_RATE, &finalFreq); } } } const int errorCount = adjustedProximityMatchedCount > 0 ? adjustedProximityMatchedCount Loading Loading
native/src/correction.cpp +54 −34 Original line number Diff line number Diff line Loading @@ -745,13 +745,13 @@ int Correction::RankingAlgorithm::calculateFinalFreq(const int inputIndex, const // Score calibration by touch coordinates is being done only for pure-fat finger typing error // cases. // TODO: Remove this constraint. if (performTouchPositionCorrection) { for (int i = 0; i < outputLength; ++i) { const int squaredDistance = correction->mDistances[i]; if (i < adjustedProximityMatchedCount) { multiplyIntCapped(typedLetterMultiplier, &finalFreq); } if (performTouchPositionCorrection && squaredDistance >= 0) { if (squaredDistance >= 0) { // Promote or demote the score according to the distance from the sweet spot static const float A = ZERO_DISTANCE_PROMOTION_RATE / 100.0f; static const float B = 1.0f; Loading @@ -773,15 +773,35 @@ int Correction::RankingAlgorithm::calculateFinalFreq(const int inputIndex, const // . // 0 R1 R2 . multiplyRate((int)(factor * 100), &finalFreq); } else if (performTouchPositionCorrection && squaredDistance == PROXIMITY_CHAR_WITHOUT_DISTANCE_INFO) { } else if (squaredDistance == PROXIMITY_CHAR_WITHOUT_DISTANCE_INFO) { multiplyRate(WORDS_WITH_PROXIMITY_CHARACTER_DEMOTION_RATE, &finalFreq); } else if (squaredDistance == ADDITIONAL_PROXIMITY_CHAR_DISTANCE_INFO) { multiplyRate(WORDS_WITH_ADDITIONAL_PROXIMITY_CHARACTER_DEMOTION_RATE, &finalFreq); } else if (i < adjustedProximityMatchedCount) { } } } else { // Demote additional proximity characters int additionalProximityCount = 0; for (int i = 0; i < outputLength; ++i) { const int squaredDistance = correction->mDistances[i]; if (squaredDistance == ADDITIONAL_PROXIMITY_CHAR_DISTANCE_INFO) { ++additionalProximityCount; } } // Promotion for a word with proximity characters for (int i = 0; i < adjustedProximityMatchedCount; ++i) { // A word with proximity corrections if (DEBUG_DICT_FULL) { AKLOGI("Found a proximity correction."); } multiplyIntCapped(typedLetterMultiplier, &finalFreq); if (i < additionalProximityCount) { multiplyRate(WORDS_WITH_ADDITIONAL_PROXIMITY_CHARACTER_DEMOTION_RATE, &finalFreq); } else { multiplyRate(WORDS_WITH_PROXIMITY_CHARACTER_DEMOTION_RATE, &finalFreq); } } } const int errorCount = adjustedProximityMatchedCount > 0 ? adjustedProximityMatchedCount Loading