You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Guard the remaining config data invariants at import time
prefixes.py asserts its own invariants at import so a bad edit fails
immediately rather than drifting until a test happens to catch it. The
other data modules had no such guard, and two of them had already
drifted.
Data fixes:
- 'esq' was in both SUFFIX_ACRONYMS and SUFFIX_NOT_ACRONYMS. Those are
the two halves of one distinction, not overlapping categories.
_classify checks suffix_words first, so the acronym membership was
unreachable -- removing it changes 0 of the 486 differential-corpus
parses. Present in v1's data too; inherited, not introduced.
- TITLES contained 'actor ' and 'television ' with trailing spaces, so
"'actor' in TITLES" was False. Parsing was unaffected because both
Lexicon and v1's SetManager normalize on ingest, which is exactly what
let the typo survive. Also inherited from v1.
Assertions added:
- suffixes.py: SUFFIX_ACRONYMS_AMBIGUOUS <= SUFFIX_ACRONYMS, and
SUFFIX_ACRONYMS disjoint from SUFFIX_NOT_ACRONYMS.
- titles.py: FIRST_NAME_TITLES <= TITLES. True by construction today
(TITLES = FIRST_NAME_TITLES | {...}), so it pins that against a
future edit making TITLES standalone.
- All six vocabulary modules plus CAPITALIZATION_EXCEPTIONS' keys:
entries stored lowercase and whitespace-free. This is the check that
found the TITLES typo.
Deliberately NOT asserted: cross-category disjointness. TITLES and
SUFFIX_ACRONYMS share 15 entries (lt, md, phd, cpt, ...) and every one
is a legitimate homograph resolved by position, as are TITLES/PREFIXES
and SUFFIX_ACRONYMS/PREFIXES.
The predicates use .strip().lower() rather than _lexicon._normalize:
config/ is the lower layer and _lexicon imports from it, so importing
back would invert the layering. Each guard was verified to fire on a
mutated copy of its own data -- an assertion that cannot fail is worth
nothing.
Note `assert` is stripped under `python -O`. These protect the shipped
data during development; Lexicon re-checks the relationships at
construction, which is what protects a caller's own vocabulary.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments