Skip to content

Name an alternative's field through one slot and one name-piece helper (#752) - #905

Merged
derek73 merged 2 commits into
masterfrom
refactor/alternative-name-field
Oct 27, 2026
Merged

derek73 merged 2 commits into
masterfrom
refactor/alternative-name-field

Conversation

@derek73

@derek73 derek73 commented Oct 27, 2026

Copy link
Copy Markdown
Owner

A follow-up to #902 (phase 2m of #752). Over three review rounds, the code that names Ambiguity.alternative's field grew into five helpers that each re-derived part of one question: where would this word land as a name word? This PR merges what they shared and gives PendingReading's BESIDE-only data its own type. No reading or alternative moves.

What changes

  • _assign._slot_field(state, seg_idx, pos, count, order) answers which field a name slot takes, by structure:

    • the family before a family comma;
    • the given part's given or middle name after one;
    • otherwise, the order the main segment's read set.

    as_a_name, _split_name_alt and _resolve_deferred each had their own copy of this; they now call it.

  • _assign._name_pieces(state, tokens, seg_idx) lists a segment's name pieces, for _split_name_alt, _resolve_deferred and _post_rules._unattached.

  • Beside(index, unfolded) in _pipeline/_state.py replaces Deferred.BESIDE and the two optional PendingReading fields beside and unfolded, which meant something only under it. PendingReading.role is now Role | Deferred | Beside, and _assemble._alternative reads the variant.

  • _name_alt's parameter family_fixed is renamed licensed. It is P5's (bound given names) join licence, which a given-name title grants as well as a family comma.

Left alone, as scoped: the snapshot and compare tooling, and as_a_middle and the P6 report site in the given-part walk. Those two look up the piece in front by raw index, which is a different question from _name_pieces. They already name the middle slot _slot_field would give them there.

Measurements (2026-10-26)

  • No alternative moves. I recorded every report's kind and alternative (reading kind, role, source) over 542,555 parses, before the change and after. The grid:

    • the case table under all three orders;
    • _REVIEW_SHAPES;
    • the snapshot corpora under six policies (the three orders, middle_as_family with and without FAMILY_FIRST, and two_family_names);
    • a generated grid of every one- to three-word run from a 21-word pool (particles, bound given names, numerals, credentials, titles, a marker, the one-case connective) in nine comma shapes.

    Of 234,112 reports, 232,739 carry an alternative, and the two records are identical. Negative control: with the given part's first slot mutated in _slot_field, the same record moves 198.

  • Snapshot and local corpora. The committed snapshot matches. snapshot.py --local tse-donors and --local ctgov-officials with --base master match with alternatives compared, since both sides' headers record them.

  • Frames. The reference row keeps 305 and Smith, John 158, and the serial benchmark passes. A name that reports pays one frame per _slot_field call, and a connective's report one more for _name_pieces: JOHN SMITH MA 223 → 224, MARIA DA SILVA E SOUZA 294 → 296. The cost is per report, not per token, and no guard moves.

  • Checks. uv run pytest passes (31,529), as do the serial suite, Python 3.15, mypy, ruff, the sphinx doctest build and the README doctest.

  • Review. The code review found no defects. It flagged two lines the refactor left unwrapped, fixed in 80f64af. A second review checked that commit and found it is wrapping only.

Refs #752.

🤖 Generated with Claude Code

derek73 and others added 2 commits October 26, 2026 23:05
#752)

The code naming Ambiguity.alternative's field (phase 2m, #902) grew
across three review rounds into five helpers that each re-derived part
of one question. _slot_field now answers which field a name slot takes
by structure (the family before a family comma, the given part's given
or middle name after one, the order's otherwise) for as_a_name,
_split_name_alt and _resolve_deferred, and _name_pieces lists a
segment's name pieces for those two and post_rules' _unattached.
Deferred.BESIDE and PendingReading's beside/unfolded fields, which
meant something only under it, become a Beside(index, unfolded)
variant of the role.

No alternative moves: a record of every report's kind and alternative
over 542,555 parses (the case table under three orders, the review
shapes, the snapshot corpora under six policies, a generated grid of
one- to three-word runs in nine comma shapes) is identical before and
after, and a mutation planted in _slot_field moves 198 of them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@derek73 derek73 added the design label Oct 27, 2026
@derek73 derek73 self-assigned this Oct 27, 2026
@derek73 derek73 added this to the 2.7 milestone Oct 27, 2026
@derek73
derek73 merged commit 2eb10f8 into master Oct 27, 2026
12 checks passed
@derek73
derek73 deleted the refactor/alternative-name-field branch October 27, 2026 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant