Phase 21: Petal learns to be an English+Portuguese pair

The plan said "Hunspell pt-PT vendored like en-US". Measuring that first is
what saved it: nspell expands affixes eagerly on construction, and European
Portuguese's 1,340 rules over 44,257 stems want over a gigabyte of browser
heap — ~340 MB for the first 12,000 entries, and no return at all after three
minutes on the whole file. So the expansion runs once at build time instead:
1,039,058 forms, 2.66 MB gzipped, read by the same nspell in 842 ms.

The obvious npm package would also have shipped the wrong language. Both
dictionary-pt and dictionary-pt-br carry VERO, the Brazilian word list, so
vendoring by name puts pt-BR spellings behind a pt-PT label — the drift
SUGGESTIONS §3 warns about, arriving through the packaging where no reviewer
can see it. The source is Projecto Natura's, and the build script now asserts
the fault lines (receção in, recepção out) before writing anything.

Spellcheck consults both dictionaries and flags only what both reject, which
is the no-detector answer to a pair with no script boundary. The word card
does the same in the other direction: "data" is a word in both languages, so
Petal shows both readings rather than guessing which she meant.

Writing the tests caught the one real bug — extendedAlphabet was a snapshot
while correct/suggest read live, and her dictionary arrives after English, so
every lookup would have resolved "cora" while the underlines were already
right.

Not done, and not claimed: the pack has not been read by a pt-PT speaker, and
the Piper voice is deferred with the deploy.

Claude-Session: https://claude.ai/code/session_016y6gyuHkQXPiEuW8RGQyua
This commit is contained in:
prosolis
2026-07-27 12:43:02 -07:00
parent 4de83d0da5
commit ccb43e5a4d
22 changed files with 1458 additions and 107 deletions
+32
View File
@@ -0,0 +1,32 @@
European Portuguese spelling dictionary
=======================================
The word list in `pt-PT.dic.gz` and the suggestion directives in `pt-PT.aff` are
derived from the LibreOffice/Projecto Natura Hunspell dictionary for European
Portuguese (`pt_PT.aff` / `pt_PT.dic`), as packaged by Debian/Ubuntu in
`hunspell-pt-pt`.
Copyright (C) 2006-2012 José João de Almeida <jj@di.uminho.pt>
Rui Vilela <ruivilela@di.uminho.pt>
Alberto Simões <ambs@di.uminho.pt>
Universidade do Minho — Projecto Natura
License: GPL-2 or LGPL-2.1 or MPL-1.1
(Petal redistributes it under the MPL-1.1 option.)
Upstream: https://natura.di.uminho.pt/ — via
https://git.libreoffice.org/dictionaries/+/refs/heads/master/pt_PT
What Petal changed
------------------
Nothing about which words are correct. `scripts/build_ptpt_dictionary.py`
applies the upstream affix rules ahead of time — Hunspell's PFX/SFX expansion
run once at build time instead of once per browser — and writes the resulting
1,039,058 surface forms as a flat word list. The shipped `.aff` keeps only
upstream's TRY/KEY/REP/MAP/WORDCHARS lines, which shape *corrections* rather
than membership. See that script's header for why the dictionary could not be
vendored in its original form.
Note that npm's `dictionary-pt` is *not* this dictionary: both it and
`dictionary-pt-br` package the Brazilian VERO word list.
+42
View File
@@ -0,0 +1,42 @@
SET UTF-8
TRY aerisontcdmlupvgbfzáhçqjíxãóéêâúõACMPSBTELGRIFVDkHJONôywUKXZWQÁYÍÉàÓèÂÚ
KEY qwertyuiop|asdfghjkl|zxcvbnm
WORDCHARS -
REP 25
REP por pro
REP pre per
REP damente mente
REP mente damente
REP iz íz
REP cao ção
REP ç ss
REP ss ç
REP c ss
REP ss c
REP ch x
REP x ch
REP cç x
REP x cç
REP k qu
REP íti ití
REP ití íti
REP issí íssi
REP ilí íli
REP íli ilí
REP ífi ifí
REP ifí ífi
REP nume mune
REP coen quen
REP concerteza com_certeza
MAP 11
MAP aá
MAP aã
MAP aâ
MAP eé
MAP eê
MAP ií
MAP cç
MAP oó
MAP oô
MAP oõ
MAP uú
Binary file not shown.