fix too aggressive correction for words with same base latin characters

This commit is contained in:
Helium314 2023-08-29 22:47:59 +02:00
parent e3240965a8
commit 305fcdf221
2 changed files with 18 additions and 0 deletions

View file

@ -416,6 +416,11 @@ public final class Suggest {
// dict locale different -> return the better match // dict locale different -> return the better match
return new boolean[]{ true, dictLocale == first.mSourceDict.mLocale }; return new boolean[]{ true, dictLocale == first.mSourceDict.mLocale };
} }
if (first.mScore < typedWordFirstOccurrenceWordInfo.mScore - 100000) {
// don't autocorrect if typed word is clearly the better suggestion
// todo: maybe this should be reduced more, to 50k or even 0
return new boolean[]{ true, false };
}
putEmptyWordSuggestions.run(); putEmptyWordSuggestions.run();
int firstScoreForEmpty = firstAndTypedWordEmptyInfos.get(0) != null ? firstAndTypedWordEmptyInfos.get(0).mScore : 0; int firstScoreForEmpty = firstAndTypedWordEmptyInfos.get(0) != null ? firstAndTypedWordEmptyInfos.get(0).mScore : 0;
int typedScoreForEmpty = firstAndTypedWordEmptyInfos.get(1) != null ? firstAndTypedWordEmptyInfos.get(1).mScore : 0; int typedScoreForEmpty = firstAndTypedWordEmptyInfos.get(1) != null ? firstAndTypedWordEmptyInfos.get(1).mScore : 0;

View file

@ -119,6 +119,19 @@ class SuggestTest {
// not corrected because of locale matching // not corrected because of locale matching
} }
@Test fun `no "lé" instead of "le"`() {
val result = shouldBeAutoCorrected(
"le",
listOf(suggestion("le", 1900000, Locale.FRENCH), suggestion("", 1500000, Locale.FRENCH)),
null,
null,
Locale.FRENCH,
thresholdModest
)
assert(!result.last()) // should not be corrected
// not corrected because of score difference
}
} }
private fun suggestion(word: String, score: Int, locale: Locale) = private fun suggestion(word: String, score: Int, locale: Locale) =