docs: correct the scope of the period-abbreviation title rule - #315
Merged
Conversation
The docs said "a leading word that ends in a period is read as a title" and that the rule "only applies to the leading run". Neither was true of any comma form. _peel_leading_titles runs at the head of the part that carries the given name -- NO_COMMA segment 0, SUFFIX_COMMA segment 0, and FAMILY_COMMA segment 1 -- so "Morse, Det. Insp. Jane" reads Det. Insp. as a title. Long-standing, verified against 1.4.0; only the description was wrong. Also replace the examples. "Major." is a whole word carrying a stray period, not an abbreviation, so it never showed why the rule exists; "Foo. Xyz." showed nothing at all. "Det. Insp." is a real rank whose parts are real abbreviations and are both absent from TITLES, so the example demonstrates the structural inference rather than merely surviving it. The closing paragraph states that only the title direction is inferred, in prose and without a doctest: whether an unrecognized trailing abbreviation should reach `suffix` is an open question, and pinning today's answer in an example would prejudge it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #315 +/- ##
=======================================
Coverage 98.46% 98.46%
=======================================
Files 41 41
Lines 2803 2803
=======================================
Hits 2760 2760
Misses 43 43 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Two facts measured after the first commit, both hidden by the "purely
positional" wording:
parse("Esq. Smith") title='Esq.' <- 'esq' is SUFFIX-only vocab
parse("John Smith Prof.") family='Prof.' <- 'prof' is TITLE vocab
So the leading shape rule fires before any vocabulary is consulted, and
trailing position has no counterpart -- which is why the comma and
no-comma paths disagree about the same word ("Smith, Prof." does give
title='Prof.').
Also record why the doctrine is not simply inverted to "vocabulary
decides": TITLES holds 692 words absent from every suffix set, many of
them ordinary surnames (king, bishop, prince, pope, judge, sheriff), so
a vocabulary-first trailing rule would read "Mary Jane King" as
title='King', family='Jane'. The period is what separates the safe case
from that one.
Drops a forward reference to an unfiled issue, and fixes a stale
"Major" example left over from the first commit.
Co-Authored-By: Claude Opus 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.
Documentation-only. No parser change;
uv run pytestand the-b doctestbuild both pass.What was wrong
usage.rstsaid the period-abbreviation inference applies to "a leading word", and that "the rule only applies to the leading run". Neither holds for any comma form._peel_leading_titlesruns at the head of the part that carries the given name —NO_COMMAsegment 0,SUFFIX_COMMAsegment 0, andFAMILY_COMMAsegment 1 — so:This is long-standing, not a 2.x regression — 1.4.0 from PyPI behaves identically. Only the description was wrong.
customize.rstrepeated the same claim and is corrected to match.New examples
Major.was the example throughout, and it is not an abbreviation — it is a whole word carrying a stray period, so it never illustrated why a period should mean anything.Foo. Xyz.illustrated less still.The examples now use
Det. Insp. Jane Morse. Detective Inspector is a real rank, both parts are real abbreviations, and neitherdetnorinspis in the shipped vocabulary — so the example actually exercises the structural inference. A line saying so was added, since previously there was no way for a reader to tell which examples depended on vocabulary and which did not.Framing
The section now opens with what the period means — a trailing period marks an abbreviation, and the parts of a name that get abbreviated are the ones standing outside it, titles and post-nominals — before stating the rule. That is the background-before-behavior shape the other domain-heavy sections use, and it makes the closing limitation legible: only the title direction is inferred.
That closing paragraph is deliberately prose with no doctest. Whether an unrecognized trailing abbreviation should reach
suffixis an open design question (issue to follow), and pinning today's answer in an example would prejudge it.Also
AGENTS.md's gotcha still namedis_leading_title(), a v1 function deleted at the M11 swap, and repeated the same wrong scope claim. It now records the per-segment scoping, all three call sites, that this is the mechanism behind Should parse("Smith, Jr.") put "Jr." in title rather than suffix? #296, and that the three trailing-period rules in the codebase resolve differently from one another.🤖 Generated with Claude Code