Skip to content

Commit 0b05473

Browse files
derek73claude
andcommitted
docs: fix what the review of the usage.rst subheadings found
Links and placement: - The leading-particle "see name-order" landed on a section that never discusses leading particles; it now targets "Where the vocabulary answers first" (labeled order-vocabulary-first), and "Family-first name order"'s own "noted at the end of this section" -- wrong before this PR, the exceptions being in the next section -- links there too. - The sentence about the whole attachment table had landed under the leading-particle subheading; it moves above it, and "covered next" becomes a link, the East Asian section no longer being next. - "That default is built for display" opened the new "Surviving a reparse" with no antecedent, which is also where the maiden-roundtrip link lands; it names the str() rendering now. - The Shakespeare example moves beside the paragraph it illustrates, and 王·Smith, the case the boundary paragraph is about, gets one. - The ambiguous-words pointer's colon introduced a doctest showing no comma rules; the pointer moves after the doctest. Claims narrowed or broadened by the move: - "two or more words before it" drops "words to spare"'s meaning: a title does not count ("Dr. John ma" keeps the surname). Fixed here and in customize.rst's identical bullet from #588. - "A word in Han, kana or hangul" read as wholly CJK; a word CARRYING such a character escapes the title reading ("田中x. Smith"). - "Every piece of each is optional" had widened from forms 1-3 to all seven (form 7's divider is not optional); it is scoped back. - The Particles bullet read as a fourth view; it is capitalized()'s second exception and merges into that bullet. - The facade parenthetical claimed initials() takes capitalized()'s whole fallback; it asks only the conjunction question (measured: J. S. for a spliced "y e"), and "only capitalized() is handed a vocabulary" is restored. Also: "East Asian forms" renamed "Forms the script carries" to match its condition-named siblings, a double blank line removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 50b077d commit 0b05473

2 files changed

Lines changed: 52 additions & 36 deletions

File tree

‎docs/customize.rst‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ The full reading of a bare marked acronym, in order:
300300
the family name even WITH words to spare (``"John Smith Ma"``).
301301
- **No signal** — all lowercase in a mixed-case name, or any spelling
302302
in a name written wholly in one case — falls back to the count: a
303-
suffix with two or more words before it (``"John Smith ma"``), the
303+
suffix with two or more name words before it, a title not counting
304+
(``"John Smith ma"``), the
304305
family name otherwise (``"JACK MA"``).
305306
- **After a comma** the count of name words before the comma decides
306307
FIRST, and the case is read only where the count leaves the word a
@@ -576,8 +577,8 @@ Family-first name order
576577

577578
``name_order`` is the one most likely to matter for data that is not
578579
in Western order. Positional input is assigned in the order you
579-
declare — with the two vocabulary exceptions noted at the end of this
580-
section — so a name written family-first — Hungarian, here — parses as
580+
declare — with the two vocabulary exceptions noted under
581+
:ref:`order-vocabulary-first` — so a name written family-first — Hungarian, here — parses as
581582
written instead of needing to be rearranged afterwards:
582583

583584
.. doctest::
@@ -717,6 +718,8 @@ family-first orders differ from each other:
717718
>>> given_last.parse("de la Cruz Juan Carlos").middle
718719
'Juan'
719720

721+
.. _order-vocabulary-first:
722+
720723
Where the vocabulary answers first
721724
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
722725

‎docs/usage.rst‎

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ Input shapes
3232
-------------
3333

3434
Three arrangements are understood by default, two more when you
35-
declare a family-first order, and two more by script alone. Every piece
36-
of each is optional.
35+
declare a family-first order, and two more by the script they are
36+
written in.
3737

3838
Understood by default
3939
~~~~~~~~~~~~~~~~~~~~~
4040

41+
Every piece of each is optional:
4142

4243
1. ``Title Given "Nickname" Middle Middle Family Suffix``
4344
2. ``Family [Suffix], Title Given (Nickname) Middle Middle[,] Suffix [, Suffix]``
@@ -71,8 +72,8 @@ displaced from the family name it belongs to; form 5's trailing word
7172
is the given name by the caller's declaration, so there is nothing
7273
there to reinterpret.
7374

74-
East Asian forms
75-
~~~~~~~~~~~~~~~~
75+
Forms the script carries
76+
~~~~~~~~~~~~~~~~~~~~~~~~
7677

7778
Two more arrangements are native East Asian forms and need no
7879
``name_order`` at all — the script itself carries the reading:
@@ -153,6 +154,12 @@ names together as easily as two surnames:
153154
>>> parse("Juan de la Vega y Rodriguez").family
154155
'de la Vega y Rodriguez'
155156

157+
One shipped vocabulary works the other way round and so is not in the
158+
table above: :mod:`surnames <nameparser.config.surnames>` *splits* a
159+
word instead of merging two, and is covered under `East Asian names`_.
160+
:doc:`customize` covers how to change which words are in each of these
161+
sets.
162+
156163
A particle at the start of a name
157164
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
158165

@@ -161,9 +168,9 @@ at the start of a name. It has no surname to attach to yet, so what
161168
decides the reading is whether it is one that can double as a given
162169
name: the particle either becomes the given name or turns the whole
163170
name into a surname. Only the first of those is ``name_order``'s
164-
question — see :ref:`name-order`, and read the given name below as the
165-
default given-first order's — since a particle that can never be a
166-
given name is the surname whatever order you declare:
171+
question — see :ref:`order-vocabulary-first`, and read the given name
172+
below as the default given-first order's — since a particle that can
173+
never be a given name is the surname whatever order you declare:
167174

168175
.. doctest::
169176

@@ -183,12 +190,8 @@ comma is the given name:
183190
>>> parse("de Mesnil, Juan").given
184191
'Juan'
185192

186-
:doc:`customize` covers how to change which words are in each of these
187-
sets, and :ref:`ambiguous-words` which particles may double as given
188-
names. One shipped
189-
vocabulary works the other way round and so is not in the table above:
190-
:mod:`surnames <nameparser.config.surnames>` *splits* a word instead of
191-
merging two, and is covered next.
193+
:ref:`ambiguous-words` covers changing which particles may double as
194+
given names.
192195

193196
.. _east-asian-names:
194197

@@ -262,7 +265,13 @@ token separator when it sits between classified-script characters
262265
qualifies), and a dot anywhere in the name reads the whole name as a
263266
transcription listing: it keeps the order it was written in and is
264267
never segmented — the role pure katakana plays for Japanese
265-
transcriptions, played here by the divider instead of the script.
268+
transcriptions, played here by the divider instead of the script:
269+
270+
.. doctest::
271+
272+
>>> shakespeare = parse("威廉·莎士比亚")
273+
>>> shakespeare.given, shakespeare.family
274+
('威廉', '莎士比亚')
266275

267276
Because only classified characters on both sides make it a divider,
268277
the same codepoint interior to a Latin-script name — the Catalan punt
@@ -272,11 +281,10 @@ undivided:
272281

273282
.. doctest::
274283

275-
>>> shakespeare = parse("威廉·莎士比亚")
276-
>>> shakespeare.given, shakespeare.family
277-
('威廉', '莎士比亚')
278284
>>> parse("Gal·la Puig").given
279285
'Gal·la'
286+
>>> parse("王·Smith").given
287+
'王·Smith'
280288

281289
The Japanese middle dot ・ (covered next) is a different mark carrying
282290
a different convention, and keeps its own reading.
@@ -684,7 +692,8 @@ family name:
684692
Surviving a reparse
685693
~~~~~~~~~~~~~~~~~~~
686694

687-
That default is built for display, and the two fields differ in what
695+
The default ``str()`` rendering is built for display, and the two
696+
fields differ in what
688697
survives it. The quoted nickname reparses as a nickname; the
689698
parenthesized maiden name reparses as a *nickname* too, so a
690699
parse-render-reparse round trip silently loses it:
@@ -807,11 +816,11 @@ names:
807816
- **Abbreviations with interior periods** are left alone (``E.T.``).
808817
- **Only the leading run** is read this way: the same word after the
809818
given name is a middle name.
810-
- **A word in Han, kana or hangul** is a name word even with a period,
819+
- **A word carrying a Han, kana or hangul character** is a name word
820+
even with a period,
811821
since those scripts write no abbreviation with one (``"田中. 太郎"``
812822
has family ``田中.``).
813823

814-
815824
.. doctest::
816825

817826
>>> parse("J. Smith").given
@@ -896,19 +905,19 @@ so branching on a kind needs no import:
896905
Credentials that are also surnames
897906
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
898907

899-
The post-nominals that double as ordinary surnames report the same way.
908+
The post-nominals that double as ordinary surnames report an ambiguity
909+
the same way.
900910
Which reading a bare one gets depends on what the writing says:
901911

902912
- **Capitals** in a name written in more than one case lean to the
903913
credential, even with no words to spare (``Jack MA``).
904914
- **Any other cased spelling** that is not wholly lowercase leans to
905915
the surname, even with words to spare (``Jack Ma``, ``John Smith Ma``).
906916
- **No signal** — all lowercase, or a name written wholly in one
907-
case — leaves it to the count: the credential with two or more words
908-
before it, the surname otherwise.
917+
case — leaves it to the count: the credential with two or more name
918+
words before it (a title does not count), the surname otherwise.
909919

910-
Either way the choice is recorded. :ref:`ambiguous-words` has the full
911-
rules, including how a comma changes them:
920+
Either way the choice is recorded:
912921

913922
.. doctest::
914923

@@ -923,6 +932,9 @@ rules, including how a comma changes them:
923932
>>> parse("John Smith Ma").family
924933
'Ma'
925934

935+
:ref:`ambiguous-words` has the full rules, including how a comma
936+
changes them.
937+
926938
Two ``Policy`` switches extend the same class to words the vocabulary
927939
does not hold. ``unlisted_dotted_suffixes`` (on by default) reads a
928940
token of two or more period-separated chunks the same way —
@@ -1022,21 +1034,22 @@ honor, so each view falls back on what it can answer without one:
10221034
capitals wherever the field is the suffix, so ``replace(suffix="mba")``
10231035
repairs to ``MBA`` and ``suffix="vi"`` to ``VI``. A credential
10241036
recognised only by its dotted shape is the exception, since the shape
1025-
is something the parse records.
1026-
- **Particles** are a fact about the whole part, and no word of a
1027-
spliced field carries a reading to derive them from, so a family set
1028-
to ``de la`` stays lowercase where the same words parsed are repaired
1029-
to ``De La``.
1037+
is something the parse records. So are particles: whether a particle
1038+
is acting as one is a fact about the whole part, and no word of a
1039+
spliced field carries a reading to derive it from, so a family set to
1040+
``de la`` stays lowercase where the same words parsed are repaired to
1041+
``De La``.
10301042
- :meth:`~nameparser.ParsedName.initials` takes no vocabulary at all,
10311043
so every word of a spliced field contributes an initial.
10321044
- ``family_particles`` and ``family_base`` are properties on the
10331045
parsed name, which holds no vocabulary of its own either:
10341046
``family_particles`` empties and ``family_base`` takes the whole
10351047
field.
10361048

1037-
(The v1 :class:`~nameparser.parser.HumanName` facade's ``initials()``
1038-
is also handed a vocabulary and takes the same fallback as
1039-
``capitalized()`` for spliced text; it is not a method of the parsed
1049+
Of the parsed name's own views, ``capitalized()`` is the only one
1050+
handed a vocabulary. (The v1 :class:`~nameparser.parser.HumanName`
1051+
facade's ``initials()`` is handed one too, and likewise asks it whether
1052+
a spliced word is a conjunction; it is not a method of the parsed
10401053
name.)
10411054

10421055
.. doctest::

0 commit comments

Comments
 (0)