Merge "Use edit distance for transposing correction"
commit
f611f24b32
|
@ -653,9 +653,10 @@ int Correction::RankingAlgorithm::calculateFinalFreq(const int inputIndex, const
|
||||||
int finalFreq = freq;
|
int finalFreq = freq;
|
||||||
|
|
||||||
// TODO: Optimize this.
|
// TODO: Optimize this.
|
||||||
// TODO: Ignoring edit distance for transposed char, for now
|
if (transposedCount > 0 || proximityMatchedCount > 0 || skipped || excessiveCount > 0) {
|
||||||
if (transposedCount == 0 && (proximityMatchedCount > 0 || skipped || excessiveCount > 0)) {
|
ed = getCurrentEditDistance(editDistanceTable, inputLength, outputIndex + 1)
|
||||||
ed = getCurrentEditDistance(editDistanceTable, inputLength, outputIndex + 1);
|
- transposedCount;
|
||||||
|
|
||||||
const int matchWeight = powerIntCapped(typedLetterMultiplier,
|
const int matchWeight = powerIntCapped(typedLetterMultiplier,
|
||||||
max(inputLength, outputIndex + 1) - ed);
|
max(inputLength, outputIndex + 1) - ed);
|
||||||
multiplyIntCapped(matchWeight, &finalFreq);
|
multiplyIntCapped(matchWeight, &finalFreq);
|
||||||
|
@ -667,21 +668,22 @@ int Correction::RankingAlgorithm::calculateFinalFreq(const int inputIndex, const
|
||||||
|
|
||||||
ed = max(0, ed - quoteDiffCount);
|
ed = max(0, ed - quoteDiffCount);
|
||||||
|
|
||||||
if (ed == 1 && (inputLength == outputIndex || inputLength == outputIndex + 2)) {
|
if (transposedCount < 1) {
|
||||||
// Promote a word with just one skipped or excessive char
|
if (ed == 1 && (inputLength == outputIndex || inputLength == outputIndex + 2)) {
|
||||||
if (sameLength) {
|
// Promote a word with just one skipped or excessive char
|
||||||
multiplyRate(WORDS_WITH_JUST_ONE_CORRECTION_PROMOTION_RATE, &finalFreq);
|
if (sameLength) {
|
||||||
} else {
|
multiplyRate(WORDS_WITH_JUST_ONE_CORRECTION_PROMOTION_RATE, &finalFreq);
|
||||||
|
} else {
|
||||||
|
multiplyIntCapped(typedLetterMultiplier, &finalFreq);
|
||||||
|
}
|
||||||
|
} else if (ed == 0) {
|
||||||
multiplyIntCapped(typedLetterMultiplier, &finalFreq);
|
multiplyIntCapped(typedLetterMultiplier, &finalFreq);
|
||||||
|
sameLength = true;
|
||||||
}
|
}
|
||||||
} else if (ed == 0) {
|
|
||||||
multiplyIntCapped(typedLetterMultiplier, &finalFreq);
|
|
||||||
sameLength = true;
|
|
||||||
}
|
}
|
||||||
adjustedProximityMatchedCount = min(max(0, ed - (outputIndex + 1 - inputLength)),
|
adjustedProximityMatchedCount = min(max(0, ed - (outputIndex + 1 - inputLength)),
|
||||||
proximityMatchedCount);
|
proximityMatchedCount);
|
||||||
} else {
|
} else {
|
||||||
// TODO: Calculate the edit distance for transposed char
|
|
||||||
const int matchWeight = powerIntCapped(typedLetterMultiplier, matchCount);
|
const int matchWeight = powerIntCapped(typedLetterMultiplier, matchCount);
|
||||||
multiplyIntCapped(matchWeight, &finalFreq);
|
multiplyIntCapped(matchWeight, &finalFreq);
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,7 +190,7 @@ static void prof_out(void) {
|
||||||
#define WORDS_WITH_MISSING_SPACE_CHARACTER_DEMOTION_RATE 67
|
#define WORDS_WITH_MISSING_SPACE_CHARACTER_DEMOTION_RATE 67
|
||||||
#define WORDS_WITH_EXCESSIVE_CHARACTER_DEMOTION_RATE 75
|
#define WORDS_WITH_EXCESSIVE_CHARACTER_DEMOTION_RATE 75
|
||||||
#define WORDS_WITH_EXCESSIVE_CHARACTER_OUT_OF_PROXIMITY_DEMOTION_RATE 75
|
#define WORDS_WITH_EXCESSIVE_CHARACTER_OUT_OF_PROXIMITY_DEMOTION_RATE 75
|
||||||
#define WORDS_WITH_TRANSPOSED_CHARACTERS_DEMOTION_RATE 60
|
#define WORDS_WITH_TRANSPOSED_CHARACTERS_DEMOTION_RATE 70
|
||||||
#define FULL_MATCHED_WORDS_PROMOTION_RATE 120
|
#define FULL_MATCHED_WORDS_PROMOTION_RATE 120
|
||||||
#define WORDS_WITH_PROXIMITY_CHARACTER_DEMOTION_RATE 90
|
#define WORDS_WITH_PROXIMITY_CHARACTER_DEMOTION_RATE 90
|
||||||
#define WORDS_WITH_MATCH_SKIP_PROMOTION_RATE 105
|
#define WORDS_WITH_MATCH_SKIP_PROMOTION_RATE 105
|
||||||
|
|
Loading…
Reference in New Issue