Skip to content

Work with GreynirEngine 3.9 and Icegrams 2.0; release 4.2.0 - #70

Merged
vthorsteinsson merged 5 commits into
masterfrom
deps-2026
Sep 30, 2026
Merged

vthorsteinsson merged 5 commits into
masterfrom
deps-2026

Conversation

@Holado

@Holado Holado commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Makes GreynirCorrect work with the newest versions of its dependencies and prepares release 4.2.0.

  • GreynirEngine 3.9.0 compatibility. Its grammar added the value sp (clitic subject: ertu, viltu) to the /pers variant, so the error production BeygingarliðurÁnUmröðunar/tala/pers/kyn → > VillaÍTölu/tala/pers/kyn expands to VillaÍTölu_et_sp/kyn and VillaÍTölu_ft_sp/kyn, which the grammar never defines. Only GreynirCorrect compiles the error productions, so the engine's own tests do not see this, and the error-detecting grammar failed to load. ErrorDetectingGrammar now appends fallback productions for these nonterminals (mirroring the p1/p2/p3 ones) when the grammar has the sp variant and does not define them itself, so it is a no-op for other engine versions.
  • Icegrams 2.0. The trigram model is no longer bundled; it is downloaded once with python -m icegrams.download. The model is now loaded in one place (reynir_correct.ngrams.load_ngrams), which re-raises ModelNotFoundError with a GreynirCorrect-specific message. The correct command prints that message and exits with status 1 instead of a traceback. ModelNotFoundError is exported from the package. README, docs and CI include the download step.
  • Spelling thresholds calibrated to the model size. The corrector's rare-word, candidate-acceptance and known-word thresholds were absolute numbers tuned to the 2019 model (~0.8 billion tokens). They are now expressed as occurrence counts and converted to log probabilities from the loaded model's total unigram count. With the 2019 model this reproduces the previous constants exactly (the whole suite passes unchanged with it); with the 2026 model (~3 billion tokens, keeps words occurring twice) a misspelling occurring a handful of times no longer counts as a known word, so e.g. víðfermt is corrected again, and skógardverg no longer gets skógardverga suggested.
  • Tests. Expectations outdated by the 2026 model are commented out with TODO notes (tímalega, arða, umsjónakennara, útá, inná are now frequent in the corpus; æxling gets a suggestion instead of a style warning; hrafnhildur is wrongly corrected to rafnhildur, which occurs 53 times in the corpus). New tests cover the grammar fallback.
  • Metadata, docs and CI. Dependency floors reynir>=3.7.0, icegrams>=2.0.0; README and docs say Python 3.11+ / PyPy 3.11+ (matching pyproject.toml); Python 3.14 classifier. Version bumped to 4.2.0.

Test plan

  • python -m pytest: 88 passed with reynir 3.9.0 + icegrams 2.0.0 on CPython 3.13
  • Same with reynir 3.8.0, and with icegrams 1.1.7 (old model): all pass
  • Test suite on PyPy 3.12 (Windows) with reynir 3.9.0 + icegrams 2.0.0
  • ruff check and mypy clean
  • correct with the model missing prints the download instructions and exits 1
  • CI matrix green (3.11–3.14, pypy-3.11)

After merging, tag 4.2.0 (or create the GitHub release) to publish to PyPI via the wheels workflow.

🤖 Generated with Claude Code

Holado and others added 4 commits September 30, 2026 13:04
… 3.12 in CI

GreynirEngine 3.9.0 added the value 'sp' (clitic subject, 'ertu') to the
/pers grammar variant, so the error production
    BeygingarliðurÁnUmröðunar/tala/pers/kyn → > VillaÍTölu/tala/pers/kyn
expands to VillaÍTölu_et_sp/kyn and VillaÍTölu_ft_sp/kyn, which the
grammar never defines. Only GreynirCorrect compiles the error
productions, so the engine's own tests do not see this, and the
error-detecting grammar failed to load with a GrammarError.
ErrorDetectingGrammar now reads the grammar text itself and appends
fallback productions for these nonterminals, mirroring the p1/p2/p3
ones, but only when the grammar has the 'sp' variant and does not
define them. This is a no-op for other engine versions.

Icegrams 2.0 no longer bundles the trigram model; it is downloaded
once with 'python -m icegrams.download'. The model is now loaded in
one place (reynir_correct.ngrams.load_ngrams), which re-raises
ModelNotFoundError with a GreynirCorrect-specific message. The
'correct' command prints that message and exits with status 1 instead
of a traceback. ModelNotFoundError is exported from the package.
README and docs describe the download step; CI downloads the model.

Dependency floors are now reynir>=3.7.0 and icegrams>=2.0.0. README
and docs say Python 3.11+ and PyPy 3.11+, matching pyproject. The
3.14 classifier is added, and pypy-3.12 joins the CI matrix (the
compiled dependencies build from source there for now).

Tests: 82 pass with reynir 3.9.0 and icegrams 2.0.0 on CPython 3.13
and PyPy 3.12. Six spelling/annotation tests still fail; their
expectations depend on the old trigram model and are left for review.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The corrector's probability thresholds were absolute log probabilities
and counts tuned to the 2019 Icegrams model (about 0.8 billion
tokens). The 2026 model has about 3 billion tokens and keeps words
occurring twice, so the same numbers meant different things: a word
had to be almost four times as frequent to escape being "rare", and a
misspelling occurring a handful of times in the corpus counted as a
known word (e.g. 'víðfermt', 4 occurrences), so it was no longer
corrected.

The thresholds are now expressed as occurrence counts (rare: up to 55,
candidate acceptance: 55, unigram acceptance: 4,900, known word: 4 per
billion tokens) and converted to log probabilities in Corrector's
constructor from the total unigram count of the loaded model. With the
2019 model this reproduces the previous constants exactly, and the
whole test suite passes with it unchanged.

The candidate acceptance rule now uses the same known-word threshold
instead of bare membership in the model, so the rare misspelling
'víðfermt' is corrected to 'víðfeðmt' again, and 'skógardverg' no
longer gets 'skógardverga' suggested (the candidate is below the
known-word threshold and hence not generated). The stupid-backoff
probability function is hoisted out of gen_candidates() into a method.

With the 2026 model, five tests still fail; all reflect misspellings or
informal forms that are now frequent in the corpus ('tímalega' 437,
'arða' 148, 'inná' 11,899, 'umsjónakennara' 19 occurrences), so they
are no longer rare or unknown to the model. Those expectations are
left for review.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The words 'tímalega', 'arða', 'umsjónakennara', 'útá' and 'inná' occur
often enough in the corpus behind the 2026 trigram model to be neither
rare nor unknown, so the rare-word warnings and corrections that the
tests expected for them no longer appear. 'æxling' now gets a W001/w
suggestion instead of a Y001/w style warning, and 'hrafnhildur' is
(wrongly) corrected to 'rafnhildur', which occurs 53 times in the
corpus. The affected assertions are commented out with TODO notes, in
the same way as earlier outdated expectations in these files; where a
sentence still has a valid expectation, that part is kept.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
GreynirCorrect is pure Python, so the PyPy 3.12 job only tested whether
the compiled dependencies (reynir, islenska, icegrams) build and run
there. None of those packages test or publish wheels for PyPy 3.12;
that coverage belongs in their own CI first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vthorsteinsson
vthorsteinsson merged commit 40c6b30 into master Sep 30, 2026
10 checks passed
@vthorsteinsson
vthorsteinsson deleted the deps-2026 branch September 30, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants