From 40c53e35a2d86294ba77e592dfa29ea8fd524b33 Mon Sep 17 00:00:00 2001 From: Andrea Cognini Date: Mon, 27 Apr 2026 10:33:07 +0200 Subject: [PATCH 1/2] feat(italiano): add 43 Italian words to prevent false-positive autocorrections Typo generators were producing valid Italian words as triggers (e.g. mare from madre, vero from verso, fato from fatto). Adding these words to italiano.txt excludes them from ALL_WORDS so they are never used as autocorrect triggers. Adds TestBlocklistRegressions with 11 regression tests covering the most critical pairs. Made-with: Cursor --- dictionaries/italiano.txt | 44 +++++++++++++++++++++++++++++++++++ tests/test_typo_generators.py | 41 ++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) diff --git a/dictionaries/italiano.txt b/dictionaries/italiano.txt index ecc5151..3a76128 100644 --- a/dictionaries/italiano.txt +++ b/dictionaries/italiano.txt @@ -3,20 +3,26 @@ # One word per line. Lines starting with # are comments. # To add a word: add it here (one per line) and open a PR. + abbiamo acqua +acro adesso aggiornamento +ahi aiutare almeno alto +ami amico +ance anche ancora andare andate andiamo anno +ano appena appuntamento aprire @@ -26,19 +32,27 @@ attenzione attraverso avere avete +avi bambino +basa bassa +bela bella bello bene bere bocca +bona +bono +bruta +bruto brutta brutto buona buonasera buongiorno buono +caio cambiamento cambiare capire @@ -64,6 +78,7 @@ con condizione conoscenza contro +coro corpo corto cosa @@ -85,6 +100,7 @@ dite documentazione domanda domani +dona donna dopo dormire @@ -108,12 +124,18 @@ facilita fai famiglia fanno +fano fare +fari +faro fate +fato fatto figlia figlio finire +fore +fori forse fra fratello @@ -137,8 +159,10 @@ informazione iniziare inoltre insieme +lago largo lasciare +lato lavorare lavoro leggere @@ -152,7 +176,9 @@ mai male mangiare mano +mare meglio +mere mese messaggio mettere @@ -166,6 +192,9 @@ modo molto momento mondo +mono +moto +nano necessario necessita nessuno @@ -189,13 +218,16 @@ organizzare organizzazione padre paese +pare parlare parola parte peggio pensare per +pero piccolo +pio poco poi portare @@ -236,6 +268,7 @@ restare risposta risultato sapere +sara scrivere scuola scusa @@ -244,15 +277,18 @@ seconda secondo sei sempre +sena sentire senza servizio +sete settimana siamo sicuramente sicuro siete sistema +site situazione soluzione soluzioni @@ -269,21 +305,26 @@ sue suo suoi sviluppo +tale tanto +temo tempo tenere terza terzo +tesa testa tipo tornare tra +tropo troppo trovare tua tue tuo tuoi +tuto tuttavia tutto ultima @@ -295,13 +336,16 @@ usare vado vai vanno +vano vecchia vecchio vedere veloce velocemente venire +vero verso +via vicino vita voi diff --git a/tests/test_typo_generators.py b/tests/test_typo_generators.py index eb355a1..6de77bf 100644 --- a/tests/test_typo_generators.py +++ b/tests/test_typo_generators.py @@ -184,3 +184,44 @@ def test_cosnt_for_const(self): def test_reutrn_for_return(self): assert "reutrn" in ge.generate_all_typos("return") + + +# --------------------------------------------------------------------------- +# Blocklist regressions — valid Italian words must never be used as triggers +# --------------------------------------------------------------------------- + +class TestBlocklistRegressions: + """Verify that blocklisted Italian words are not generated as typos.""" + + def test_mare_not_a_typo_of_madre(self): + assert "mare" not in ge.generate_all_typos("madre") + + def test_vero_not_a_typo_of_verso(self): + assert "vero" not in ge.generate_all_typos("verso") + + def test_lago_not_a_typo_of_largo(self): + assert "lago" not in ge.generate_all_typos("largo") + + def test_lato_not_a_typo_of_alto(self): + assert "lato" not in ge.generate_all_typos("alto") + + def test_fato_not_a_typo_of_fatto(self): + assert "fato" not in ge.generate_all_typos("fatto") + + def test_vano_not_a_typo_of_vanno(self): + assert "vano" not in ge.generate_all_typos("vanno") + + def test_sete_not_a_typo_of_siete(self): + assert "sete" not in ge.generate_all_typos("siete") + + def test_temo_not_a_typo_of_tempo(self): + assert "temo" not in ge.generate_all_typos("tempo") + + def test_moto_not_a_typo_of_molto(self): + assert "moto" not in ge.generate_all_typos("molto") + + def test_faro_not_a_typo_of_faro_accented(self): + assert "faro" not in ge.generate_all_typos("farò") + + def test_pero_not_a_typo_of_pero_accented(self): + assert "pero" not in ge.generate_all_typos("però") From 36537965cb99079bf215065b7ae23829f1fd7a21 Mon Sep 17 00:00:00 2001 From: Andrea Cognini Date: Mon, 27 Apr 2026 11:22:41 +0200 Subject: [PATCH 2/2] refactor(pr10): address review comments on false-positive blocklist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove extra blank line after italiano.txt header - Move `site` from italiano.txt to dev.txt (English/tech term per CONTRIBUTING) - Replace 11 individual TestBlocklistRegressions methods with a single parametrized test covering 18 trigger/source pairs, including 7 new high-value cases (fano/fanno, tropo/troppo, tuto/tutto, sena/senza, site/siete, sara/sarà and previously ambiguous farò/però names) - Add class comment clarifying the intentional use of real ALL_WORDS Made-with: Cursor --- dictionaries/dev.txt | 1 + dictionaries/italiano.txt | 2 -- tests/test_typo_generators.py | 66 ++++++++++++++++------------------- 3 files changed, 32 insertions(+), 37 deletions(-) diff --git a/dictionaries/dev.txt b/dictionaries/dev.txt index 2984454..22db13e 100644 --- a/dictionaries/dev.txt +++ b/dictionaries/dev.txt @@ -219,6 +219,7 @@ settings shadow sidebar singleton +site skeleton slider snapshot diff --git a/dictionaries/italiano.txt b/dictionaries/italiano.txt index 3a76128..e4fc8bd 100644 --- a/dictionaries/italiano.txt +++ b/dictionaries/italiano.txt @@ -3,7 +3,6 @@ # One word per line. Lines starting with # are comments. # To add a word: add it here (one per line) and open a PR. - abbiamo acqua acro @@ -288,7 +287,6 @@ sicuramente sicuro siete sistema -site situazione soluzione soluzioni diff --git a/tests/test_typo_generators.py b/tests/test_typo_generators.py index 6de77bf..6cd37b6 100644 --- a/tests/test_typo_generators.py +++ b/tests/test_typo_generators.py @@ -190,38 +190,34 @@ def test_reutrn_for_return(self): # Blocklist regressions — valid Italian words must never be used as triggers # --------------------------------------------------------------------------- -class TestBlocklistRegressions: - """Verify that blocklisted Italian words are not generated as typos.""" - - def test_mare_not_a_typo_of_madre(self): - assert "mare" not in ge.generate_all_typos("madre") - - def test_vero_not_a_typo_of_verso(self): - assert "vero" not in ge.generate_all_typos("verso") - - def test_lago_not_a_typo_of_largo(self): - assert "lago" not in ge.generate_all_typos("largo") - - def test_lato_not_a_typo_of_alto(self): - assert "lato" not in ge.generate_all_typos("alto") - - def test_fato_not_a_typo_of_fatto(self): - assert "fato" not in ge.generate_all_typos("fatto") - - def test_vano_not_a_typo_of_vanno(self): - assert "vano" not in ge.generate_all_typos("vanno") - - def test_sete_not_a_typo_of_siete(self): - assert "sete" not in ge.generate_all_typos("siete") - - def test_temo_not_a_typo_of_tempo(self): - assert "temo" not in ge.generate_all_typos("tempo") - - def test_moto_not_a_typo_of_molto(self): - assert "moto" not in ge.generate_all_typos("molto") - - def test_faro_not_a_typo_of_faro_accented(self): - assert "faro" not in ge.generate_all_typos("farò") - - def test_pero_not_a_typo_of_pero_accented(self): - assert "pero" not in ge.generate_all_typos("però") +# These tests intentionally use the real ALL_WORDS (no isolated_all_words +# fixture) because the whole point is to verify that words added to the +# dictionaries are actually loaded at runtime and excluded from typo generation. +@pytest.mark.parametrize( + ("trigger", "source"), + [ + # Transpositions of common Italian words + ("mare", "madre"), + ("vero", "verso"), + ("lago", "largo"), + ("lato", "alto"), + ("vano", "vanno"), + ("temo", "tempo"), + ("moto", "molto"), + ("sena", "senza"), + # Missing-double variants + ("fato", "fatto"), + ("fano", "fanno"), + ("tropo", "troppo"), + ("tuto", "tutto"), + # Missing-char variants (including one from dev.txt) + ("sete", "siete"), + ("site", "siete"), + # Accent (missing-accent) variants + ("faro", "farò"), + ("pero", "però"), + ("sara", "sarà"), + ], +) +def test_blocklisted_word_not_generated_as_typo(trigger, source): + assert trigger not in ge.generate_all_typos(source)