am 534faf1c
: Merge "Separate the logic for touch caribration again"
* commit '534faf1cd0b3e99a4633217f34dd9f683cd65e35': Separate the logic for touch caribration again
This commit is contained in:
commit
640f12361c
1 changed files with 54 additions and 34 deletions
|
@ -745,41 +745,61 @@ int Correction::RankingAlgorithm::calculateFinalFreq(const int inputIndex, const
|
||||||
// Score calibration by touch coordinates is being done only for pure-fat finger typing error
|
// Score calibration by touch coordinates is being done only for pure-fat finger typing error
|
||||||
// cases.
|
// cases.
|
||||||
// TODO: Remove this constraint.
|
// TODO: Remove this constraint.
|
||||||
for (int i = 0; i < outputLength; ++i) {
|
if (performTouchPositionCorrection) {
|
||||||
const int squaredDistance = correction->mDistances[i];
|
for (int i = 0; i < outputLength; ++i) {
|
||||||
if (i < adjustedProximityMatchedCount) {
|
const int squaredDistance = correction->mDistances[i];
|
||||||
multiplyIntCapped(typedLetterMultiplier, &finalFreq);
|
if (i < adjustedProximityMatchedCount) {
|
||||||
|
multiplyIntCapped(typedLetterMultiplier, &finalFreq);
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
static const float C = 0.5f;
|
||||||
|
static const float MIN = 0.3f;
|
||||||
|
static const float R1 = NEUTRAL_SCORE_SQUARED_RADIUS;
|
||||||
|
static const float R2 = HALF_SCORE_SQUARED_RADIUS;
|
||||||
|
const float x = (float)squaredDistance
|
||||||
|
/ ProximityInfo::NORMALIZED_SQUARED_DISTANCE_SCALING_FACTOR;
|
||||||
|
const float factor = max((x < R1)
|
||||||
|
? (A * (R1 - x) + B * x) / R1
|
||||||
|
: (B * (R2 - x) + C * (x - R1)) / (R2 - R1), MIN);
|
||||||
|
// factor is piecewise linear function like:
|
||||||
|
// A -_ .
|
||||||
|
// ^-_ .
|
||||||
|
// B \ .
|
||||||
|
// \_ .
|
||||||
|
// C ------------.
|
||||||
|
// .
|
||||||
|
// 0 R1 R2 .
|
||||||
|
multiplyRate((int)(factor * 100), &finalFreq);
|
||||||
|
} 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 (performTouchPositionCorrection && squaredDistance >= 0) {
|
// Demote additional proximity characters
|
||||||
// Promote or demote the score according to the distance from the sweet spot
|
int additionalProximityCount = 0;
|
||||||
static const float A = ZERO_DISTANCE_PROMOTION_RATE / 100.0f;
|
for (int i = 0; i < outputLength; ++i) {
|
||||||
static const float B = 1.0f;
|
const int squaredDistance = correction->mDistances[i];
|
||||||
static const float C = 0.5f;
|
if (squaredDistance == ADDITIONAL_PROXIMITY_CHAR_DISTANCE_INFO) {
|
||||||
static const float MIN = 0.3f;
|
++additionalProximityCount;
|
||||||
static const float R1 = NEUTRAL_SCORE_SQUARED_RADIUS;
|
}
|
||||||
static const float R2 = HALF_SCORE_SQUARED_RADIUS;
|
}
|
||||||
const float x = (float)squaredDistance
|
// Promotion for a word with proximity characters
|
||||||
/ ProximityInfo::NORMALIZED_SQUARED_DISTANCE_SCALING_FACTOR;
|
for (int i = 0; i < adjustedProximityMatchedCount; ++i) {
|
||||||
const float factor = max((x < R1)
|
// A word with proximity corrections
|
||||||
? (A * (R1 - x) + B * x) / R1
|
if (DEBUG_DICT_FULL) {
|
||||||
: (B * (R2 - x) + C * (x - R1)) / (R2 - R1), MIN);
|
AKLOGI("Found a proximity correction.");
|
||||||
// factor is piecewise linear function like:
|
}
|
||||||
// A -_ .
|
multiplyIntCapped(typedLetterMultiplier, &finalFreq);
|
||||||
// ^-_ .
|
if (i < additionalProximityCount) {
|
||||||
// B \ .
|
multiplyRate(WORDS_WITH_ADDITIONAL_PROXIMITY_CHARACTER_DEMOTION_RATE, &finalFreq);
|
||||||
// \_ .
|
} else {
|
||||||
// C ------------.
|
multiplyRate(WORDS_WITH_PROXIMITY_CHARACTER_DEMOTION_RATE, &finalFreq);
|
||||||
// .
|
}
|
||||||
// 0 R1 R2 .
|
|
||||||
multiplyRate((int)(factor * 100), &finalFreq);
|
|
||||||
} else if (performTouchPositionCorrection
|
|
||||||
&& 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) {
|
|
||||||
multiplyRate(WORDS_WITH_PROXIMITY_CHARACTER_DEMOTION_RATE, &finalFreq);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue