diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/latin/Suggest.java b/app/src/main/java/org/dslul/openboard/inputmethod/latin/Suggest.java index 92b4992bf..7d91c2559 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/latin/Suggest.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/latin/Suggest.java @@ -416,6 +416,11 @@ public final class Suggest { // dict locale different -> return the better match 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(); int firstScoreForEmpty = firstAndTypedWordEmptyInfos.get(0) != null ? firstAndTypedWordEmptyInfos.get(0).mScore : 0; int typedScoreForEmpty = firstAndTypedWordEmptyInfos.get(1) != null ? firstAndTypedWordEmptyInfos.get(1).mScore : 0; diff --git a/app/src/test/java/org/dslul/openboard/inputmethod/latin/SuggestTest.kt b/app/src/test/java/org/dslul/openboard/inputmethod/latin/SuggestTest.kt index 712f1c4ab..845686a89 100644 --- a/app/src/test/java/org/dslul/openboard/inputmethod/latin/SuggestTest.kt +++ b/app/src/test/java/org/dslul/openboard/inputmethod/latin/SuggestTest.kt @@ -119,6 +119,19 @@ class SuggestTest { // not corrected because of locale matching } + @Test fun `no "lé" instead of "le"`() { + val result = shouldBeAutoCorrected( + "le", + listOf(suggestion("le", 1900000, Locale.FRENCH), suggestion("lé", 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) =