Repository navigation
Fill Reading.languages from the reading index (3.0, 4a's follow-up) - #944
Merged
Merged
Conversation
, 4a) codecov/patch flagged the return for a given-part token in no segment, which the pipeline never builds; an empty default keeps parse total without a branch no input reaches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 84ac249)
) Each token's reading, and each report's alternative, now names the shipped language files that list the word the way it was read, looked up at assemble in 3a's reading index (#753) by the word and the kind taken. A reading by shape or position names none, and so does a word from a caller's own Lexicon or the Korean surname list. The field takes ADDED_IN and compare=False, so 2.7 and 2.8 pickles load with () and no comparison moves; no role, tag or alternative moves and the snapshot is unchanged. Two bounded memos keep the lookups off the frame count: steady per-parse frames are unchanged, and the first parse that meets a listed word pays about 1 ms once to load the index. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the docs
The code review found a nickname between a split credential's words
joining the wrong neighbour ('Ph. "Bob" D.'), and unions over a word's
parts or a report's words left unsorted against the documented order;
both are fixed, the second word of such a split now taking its first
word's reading across the nickname. The alternative's union is a loop,
not a generator, so a report pays no resumed frame per word.
The design-docs review found the RFC and a Standing line still saying
the field was unfilled, an overbroad claim about which parses load the
index (any word the parse's own Lexicon lists does, filed or not), and
in-place rewrites of earlier dated entries, which are reverted in favour
of a SUPERSEDES line and a head marker on decisions/A1.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…whole (#754) Answers the orchestrator's review of #944. A name reading now takes the rows listing the word as a name of the field it lands in, so 'Ma' as a family name names en and not fil, which lists it only as given. A word joining listed words is read by its parts only where the parse's own Lexicon does not list it whole, so a caller's 'zzq-dr' title names none of dr's files, and a word listed whole without its periods ('Lt.Gen.' as 'ltgen') is found whole. Reading.languages refuses a mapping and a non-iterable with a message naming the fix. The docs give the uncached first-load cost beside the cached one and name languages_of as the lookup a parse makes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… middle (#754) Answers the review of 2aab546. The check that the parse's own Lexicon lists a word whole ran as a frame on every parse for each listed word whose whole form no file holds ('van' as a family name, 'Fils' as a middle name); it now runs only where some file holds the word's parts, behind two memos, so those words pay no frame again and only a word read by its parts pays one. A middle word that middle_as_family folds into the family names the files listing it as a given name, as without the policy, and an alternative's files are read before that fold. Test rows now hold the maiden, middle and bound-given arms of the field lookup and the period-free arm of the lexicon check; each fails under its own mutation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…#754) Codecov flagged five lines of the diff. The two that clear a reading's files when the parse's own Lexicon lists the word whole are reachable, for a token and for a report's alternative, and a test now reaches each (a caller's 'MD-ZZ' and 'MA-ZZ'); each fails under its own mutation. The other three no input reaches: a kind no file row holds is read only by shape, so _kinds answers an empty set instead of None, and a split credential's first word always has its second after it, since classify tags them as a pair, so the partner lookup ends in an expression with an empty default rather than a branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completes 3.0 sub-phase 4a (#754): each token's
Token.reading, and each report'sAmbiguity.alternative, now names the shipped language files that list the word the way it was read. The lookup uses 3a's reading index (#753).What changed
Reading.languages: tuple[str, ...] = (),compare=False,metadata={ADDED_IN: "3.0.0"}.Readingshipped in 2.7, so aReadingpickled by 2.7 or 2.8 loads with(). The new fixturetests/v2/data/parsedname_v28_alternative.picklewas made by the released 2.8.0 wheel._REFUSED_SKEWS).TypeError, a bare str, a mapping, a non-iterable and a non-str tag.Reading('particle' as 'family', 'vocabulary', in es fr it nl pt)._pipeline/_assemble.py) for avocabularyordeclaredreading only, through_reading_index.languages_of(text, categories)._CATEGORIES). Every suffix kind matches the word's suffix rows, since a word has one suffix kind.M.A,Lt.Gen.asltgen).familyfor a family or maiden word,givenfor a given or middle word (a middle thatmiddle_as_familyfolds included), and bound given names in either.Ph.D.), passing over a nickname written between its words.Lt.Gov.,M.D./Ph.D.,MD;), never dividing at a combining mark (प्रोफे.डॉ.→hi,mr). This happens only where the parse's ownLexicondoesn't list the word whole, so a caller's ownzzq-drtitle names no file._pipeline/_assemble.pymay importnameparser._reading_index(tests/v2/test_layering.py).84ac249e(4a's coverage fix to_opens_its_segment), kept as its own commit.Sample readings
de(Dr. Juan de la Vega III)particle,vocabulary,es fr it nl ptPhD(John Smith PhD)credential,vocabulary,en김(김민준)name,vocabulary,(): the Korean surname list stays outside the per-word files先生(王小明先生)post-nominal,vocabulary,ja zhJuanname,position,()MA(JOHN SMITH MA)nameasfamily,declared,en(fillistsmaonly as a given name)Over the snapshot's 6,360 names (20,804 tokens), 3,935 readings are
vocabularyordeclared, and 3,750 of them name a file. Of the 185 that name none, 157 are Korean surnames split off by the list, and 28 are declared names read into a field no file lists them in (vanas a family name, for example;nllists it as given).Costs
Measured 2026-10-29 on Python 3.11.17 against
bd02d68f.PYTHONDONTWRITEBYTECODE=1, as in some containers) it is about 16 ms.Lexicon.김민준and a caller's own title load the index;John Smithdoes not.tools/perf/call_count.pygives 311.00 → 311.48 on 3.11.lru_cachememos keep the lookups off the frame count, since a hit runs in C._CALL_BASELINEis not moved.Lt.Gov.,M.D./Ph.D.). It checks that the parse's ownLexicondoesn't list the word whole, and since that depends on the lexicon it can't be memoized on the text.bd02d68ffailed the same way (delimiter_pairs, thentitle_chain), so this is load noise.No parse moves
No role, tag or alternative kind/role/source changes.
languagesis not compared, and the snapshot does not record readings, so the committed snapshot is byte-identical andtest_snapshotpasses unchanged. One 4aToken.readingmoves, on a shape the snapshot does not hold: the second word of a split credential with a nickname between its words (D.inJohn Smith Ph. "Bob" D.) now takes its first word'scredential/vocabularyreading, where 4a gavecredential/position. The decisions entry records it.Not done here
Jr/Sr(4b). This lookup does not make it free. The kind a token takes is named by_vocab.suffix_kind, which also namesAmbiguity.alternative. Reading the kind from the index at assemble alone would split the two, and reading it insidesuffix_kindwould move alternatives. The strict xfails stand.languages_of's on-by-default filter, and the memo's key, are the places to change. A note in the session notes tells the 3b lane.Docs (same-PR amendment)
Token.readingitem, work-order row 4a, and theLexiconopen question.SUPERSEDES:line for decisions/A1's 2.7 decline oflanguages, and a new Standing line. A1's entry head carries the partial-supersede marker. The earlier 3a and 4a entries are left as written; the new entry says what changed.nameparser/_pipeline/AGENTS.md,docs/usage.rst(a doctest), and a release-log bullet.Checks run:
uv run pytest(also on 3.15),uv run pytest -n0 -m serial,uv run mypy,uv run ruff check,sphinx-build -b doctest. Reviewed by a design-docs review and a code review; both rounds' findings are answered in the second commit.Refs #754, #753.
🤖 Generated with Claude Code