Merge "Promote a word with only one proximity character."
This commit is contained in:
commit
0851abf999
2 changed files with 13 additions and 1 deletions
|
@ -138,13 +138,14 @@ static void prof_out(void) {
|
||||||
#define SUGGEST_WORDS_WITH_SPACE_PROXIMITY true
|
#define SUGGEST_WORDS_WITH_SPACE_PROXIMITY true
|
||||||
|
|
||||||
// The following "rate"s are used as a multiplier before dividing by 100, so they are in percent.
|
// The following "rate"s are used as a multiplier before dividing by 100, so they are in percent.
|
||||||
#define WORDS_WITH_MISSING_CHARACTER_DEMOTION_RATE 90
|
#define WORDS_WITH_MISSING_CHARACTER_DEMOTION_RATE 80
|
||||||
#define WORDS_WITH_MISSING_CHARACTER_DEMOTION_START_POS_10X 12
|
#define WORDS_WITH_MISSING_CHARACTER_DEMOTION_START_POS_10X 12
|
||||||
#define WORDS_WITH_MISSING_SPACE_CHARACTER_DEMOTION_RATE 80
|
#define WORDS_WITH_MISSING_SPACE_CHARACTER_DEMOTION_RATE 80
|
||||||
#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 60
|
||||||
#define FULL_MATCHED_WORDS_PROMOTION_RATE 120
|
#define FULL_MATCHED_WORDS_PROMOTION_RATE 120
|
||||||
|
#define WORDS_WITH_JUST_ONE_PROXIMITY_CHARACTER_PROMOTION_RATE 110
|
||||||
|
|
||||||
// This should be greater than or equal to MAX_WORD_LENGTH defined in BinaryDictionary.java
|
// This should be greater than or equal to MAX_WORD_LENGTH defined in BinaryDictionary.java
|
||||||
// This is only used for the size of array. Not to be used in c functions.
|
// This is only used for the size of array. Not to be used in c functions.
|
||||||
|
|
|
@ -523,6 +523,9 @@ inline int UnigramDictionary::calculateFinalFreq(const int inputIndex, const int
|
||||||
* (10 * mInputLength - WORDS_WITH_MISSING_CHARACTER_DEMOTION_START_POS_10X)
|
* (10 * mInputLength - WORDS_WITH_MISSING_CHARACTER_DEMOTION_START_POS_10X)
|
||||||
/ (10 * mInputLength
|
/ (10 * mInputLength
|
||||||
- WORDS_WITH_MISSING_CHARACTER_DEMOTION_START_POS_10X + 10);
|
- WORDS_WITH_MISSING_CHARACTER_DEMOTION_START_POS_10X + 10);
|
||||||
|
if (DEBUG_DICT) {
|
||||||
|
LOGI("Demotion rate for missing character is %d.", demotionRate);
|
||||||
|
}
|
||||||
multiplyRate(demotionRate, &finalFreq);
|
multiplyRate(demotionRate, &finalFreq);
|
||||||
} else {
|
} else {
|
||||||
finalFreq = 0;
|
finalFreq = 0;
|
||||||
|
@ -539,6 +542,7 @@ inline int UnigramDictionary::calculateFinalFreq(const int inputIndex, const int
|
||||||
int lengthFreq = TYPED_LETTER_MULTIPLIER;
|
int lengthFreq = TYPED_LETTER_MULTIPLIER;
|
||||||
for (int i = 0; i < depth; ++i) lengthFreq *= TYPED_LETTER_MULTIPLIER;
|
for (int i = 0; i < depth; ++i) lengthFreq *= TYPED_LETTER_MULTIPLIER;
|
||||||
if (lengthFreq == matchWeight) {
|
if (lengthFreq == matchWeight) {
|
||||||
|
// Full exact match
|
||||||
if (depth > 1) {
|
if (depth > 1) {
|
||||||
if (DEBUG_DICT) {
|
if (DEBUG_DICT) {
|
||||||
LOGI("Found full matched word.");
|
LOGI("Found full matched word.");
|
||||||
|
@ -548,6 +552,13 @@ inline int UnigramDictionary::calculateFinalFreq(const int inputIndex, const int
|
||||||
if (sameLength && transposedPos < 0 && skipPos < 0 && excessivePos < 0) {
|
if (sameLength && transposedPos < 0 && skipPos < 0 && excessivePos < 0) {
|
||||||
finalFreq = capped255MultForFullMatchAccentsOrCapitalizationDifference(finalFreq);
|
finalFreq = capped255MultForFullMatchAccentsOrCapitalizationDifference(finalFreq);
|
||||||
}
|
}
|
||||||
|
} else if (lengthFreq / 2 == matchWeight && transposedPos < 0 && skipPos < 0
|
||||||
|
&& excessivePos < 0 && depth > 1) {
|
||||||
|
// Full match except only one proximity correction
|
||||||
|
if (DEBUG_DICT) {
|
||||||
|
LOGI("Found one proximity correction.");
|
||||||
|
}
|
||||||
|
multiplyRate(WORDS_WITH_JUST_ONE_PROXIMITY_CHARACTER_PROMOTION_RATE, &finalFreq);
|
||||||
}
|
}
|
||||||
if (sameLength) finalFreq *= FULL_WORD_MULTIPLIER;
|
if (sameLength) finalFreq *= FULL_WORD_MULTIPLIER;
|
||||||
return finalFreq;
|
return finalFreq;
|
||||||
|
|
Loading…
Reference in a new issue