Repository navigation
Simplify _comma.py, _pieces.py and _vocab.py - #1433
Merged
Merged
Conversation
The 3.1 release's simplify pass over three modules this cycle changed. Readings unchanged: snapshot.jsonl byte-identical, every agreement view matches its record. - _vocab: T8's unambiguous title-or-suffix test after a glued stop, written twice (glued_cuts, glued_saint_cut), is one helper - _vocab: one joiner constant for O9's capitals word and the Cyrillic order key, which held the same six characters under two names - _vocab: is_initial_chunk asks _is_cased_letter; is_capitals_word drops a counter its chunk count implies and a dead while-else - _vocab: glued_cuts and glued_saint_cut ask their C-level matches before the fold's frame - _comma: one helper builds the credential fork C13 and C16 report; C16's one-element run set is an index; C13 keeps the whole-name answer it computes; C6's contrast fills the box its helpers read - comments trimmed to the citation form, history left in decisions/; _comma's Reads: line names the sets it reads directly Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Release checklist step 0: a /simplify pass over
nameparser/_pipeline/_comma.py,_pieces.pyand_vocab.py. It ran four review angles: reuse, simplification, efficiency, altitude. No reading moves.Simplifications
_vocab: T8's "an unambiguous title or suffix word after the stop is no name" test was written out twice, word for word, inglued_cutsandglued_saint_cut. It is now one helper,_claimed_after_the_stop._vocab:_CYRILLIC_JOINERS(Should a Mongolian choice read the father's name first? (Ухнаагийн Хүрэлсүхgives given 'Ухнаагийн', family 'Хүрэлсүх') #1237) and_CAPITALS_JOINERS(O9) held the same six characters under two names. They are now one_NAME_JOINERS, whose comment names both readers._vocab:is_initial_chunkasks_is_cased_letterinstead of restating it inline._vocab:is_capitals_worddrops thecapitalscounter, sincecapitals >= longestalways holds, and a deadwhile … elsearm._vocab:glued_cutsandglued_saint_cutnow run their C-level matches before the_normalizeframe. Forglued_cuts, a bare run of letters returns()up front, which is the walk's first answer anyway withtitledfalse._vocab: the stray secondfrom nameparser._lexicon import _HYPHEN_CHARSmerged into the existing import, and the hyphen comment says the constant lives in_lexicon._comma:_credential_forkbuilds theSUFFIX_OR_NAMEreport that C13 (decide) and C16 (_run_read_as_initials) each built by hand. The message text is byte-identical._comma: C16'sruns: set[int]never held more than one index. It becomesinitials_at: int | None, and theat = -1,firstandruns.clear()scaffolding goes with it.segment_suffix_reading's signature is unchanged._comma: the C13 block keeps the_whole_nameanswer it computes, where the laterif not listingasked again._whole_namereads onlyseg0, and nothing in between changes it._comma: C6's caps loop now writes the contrast into thecontrast_boxthat_credentials_beside,_listed_credentials_behindand_capitals_in_contrastread, so_name_contrastis no longer computed twice. The box is empty whenever the local isNone, so the two stay in step._comma'sReads:line now namesgeneration_wordsand the two ambiguous suffix sets that_a_names_wordreads directly (ShouldJane Doe, BM PhDreadBMas a credential, not the given name? #1323). The grep listed them and the line did not.Comments trimmed to the citation form:
_pieces.leading_titles' H3 block drops its two residuals and its 8-call measurement. decisions/H3 already holds both._pieces._chain_unitsdrops the Should a credential word inside abinchain stay in it? (Ahmad bin Abd Rahmangives familyRahman, patronymicbin Abd) #1177 review example. decisions/P2 holds it._comma._given_name_written_shortnow points at decisions/C13 (Read Md., Mohd and Moh as Muhammad written short, MD still the degree #1395) instead of naming the review round._vocab's C3 count comment drops "Fix P13's trailing-title test and P2's chain stopping at a suffix word written as a name #1259 left this count as it was".No decisions file needed new text, so no doc under docs/design/ changed.
tests/v2/test_layering.py's_UNGUARDED_READSgoes from 203 to 198, with its provenance line. The T8 fold removed direct_setsreads, and the recorded control counts them.Lines:
_comma.py1166 → 1178 (the helper and a wider Reads: line),_pieces.py2615 → 2603,_vocab.py3367 → 3367.Measurements
uv run pytest: 49786 passed, 45 skipped, 3 xfailed.uv run pytest -n0 -m serial: 38 passed.uv run mypyanduv run ruff checkare clean.git diff --stat origin/master -- tools/differentialis empty, andtests/v2/test_snapshot.pypasses.uv run python tools/differential/cldr_agreement.py: all seven views match their record.Frames, py3.11. Each name ran in a fresh process with one warm-up parse of the name itself, master vs this branch.
_CALL_BASELINEis not edited._calls_per_parse)Smith, JohnJohn Smith, MD, PhDJane Doe, BM PhD(C6 contrast reused)John Smith, Md(C13 whole name kept)J.R.R. Tolkien(letter run returns early)Smith, J.P.(_credential_fork)St.John Smith(_claimed_after_the_stop, asked twice)Reads: headers
grep -oE '\b(policy|lexicon|lex)(\._sets)?\.[a-z][a-z_]*'was compared against each docstring._commanow lists every set the grep finds; the policy fields it reads go throughstate.policyand its helpers and were already named._piecesand_vocabare not stages and carry noReads:line.Branches called dead
The only branch removed is
is_capitals_word'swhile … else: i = -1. It is dead by construction: the loop ends normally only ati == 0, whereword[:0]is empty. The guard is nowif i and not all(...), which also keeps the generator's frame off the common path.Behavior-changing candidates
None found among the applied changes. One efficiency finding was not applied because it is not equivalent by construction.
decide's C16 block appends every dotted run of initials tomaybe, even behind a full name, soJohn Smith, M.D.paysname_word_countand its helpers.elif initials_at not in maybe and (maybe or _lone_word(state, seg0)).maybepath (the listing early return,head_named=True).--base) were not read.Follow-ups outside these files
_pieces.trailing_titles' comment on the양. 지훈splits the given name in half #323 veto describes the word test that now lives in_classify(Write one classify tag for "H5's trailing chain takes this word" #1171). The reason would read better beside_classify'sCHAIN_TITLE_TAGloop, which another worker owns. It was left in place here, since it is still true.🤖 Generated with Claude Code