Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/release_log.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Release Log
- **Add Parser.matching(), to group and compare names from several sources.** ``Parser().matching().check("John A. Smith", "J. Smith")`` is consistent, with a table reading the given name as an initial and the middle name as written on one side only, where ``parse("John A. Smith").matches("J. Smith")`` is ``False``, and ``keys()`` gives grouping keys that a consistent pair always shares. Consistent means nothing in the two names contradicts the match, not that they are one person, and it is not transitive (``J. Smith`` is consistent with ``John Smith`` and with ``Jane Smith``). An opt-in outcome, ``familiar-form``, reads a familiar form as its longer given name (``Bill`` / ``William``, ``Ricky`` / ``Richard``), from pairs seeded from Jörg Michael's nam_dict and a reviewed selection of Old Dominion University's nicknames list. See :ref:`matching-names`. :issue:`1006`, :issue:`1267`, :issue:`1276`, :issue:`1261`, :issue:`1263`
- **Add the order report, on a name of one word followed by initials.** ``parse("Kavitha S").ambiguities`` holds an ``order`` ambiguity, which names no ``alternative`` (the other reading lays out the whole name: ``name_order=FAMILY_FIRST`` reads it), where 2.0.0 through 3.0.1 report nothing; the reading itself does not change. Capitals written as one word with no full stops (``Armitage JO``) are not reported, being written as a short surname is (``Zhi LI``). :issue:`1137`, :issue:`1254`
- **Add Policy.initials_as_family, to read the letters ending a name as its family name.** ``Parser(policy=Policy(initials_as_family=True)).parse("Lakshmi R S")`` gives given ``Lakshmi``, family ``R S``, where 1.4.0 through 3.0.1, and the default still, give middle ``R``, family ``S``. ``locales.NE`` turns it on, and ``Parser.suggest()`` suggests it for a list whose names repeat one run of letters (Nepal's ``B K``). The same string is a middle and a family initial in many lists and a byline written surname first in a bibliography, so it is off by default. :issue:`1163`, :issue:`1254`
- **Add Parser.suggest(), to read the settings a list of names is written in.** ``Parser().suggest(["Priem Jason", "Kim Minjun", "Wang Xiaoming", "Nguyen Anh", "Jason Priem"]).parser.parse("Priem Jason")`` gives given ``Jason``, family ``Priem``, where ``Parser().parse("Priem Jason")`` gives given ``Priem``, family ``Jason``, the list carrying the evidence for a family-first ``name_order``; a group of East Slavic or Turkic patronymics gets the patronymic rule too. A list of names with no common surname or given name carries no evidence and keeps the base, and moving the base takes from 5 names (Chinese, Korean, Czech) to 200 (Indian). See :ref:`suggest-settings`. :issue:`1308`
- **Add Parser.suggest(), to read the settings a list of names is written in.** ``Parser().suggest(["Smith Mary", "Kim Minjun", "Wang Xiaoming", "Nguyen Anh", "Mary Smith"]).parser.parse("Smith Mary")`` gives given ``Mary``, family ``Smith``, where ``Parser().parse("Smith Mary")`` gives given ``Smith``, family ``Mary``, the list carrying the evidence for a family-first ``name_order``; a group of East Slavic or Turkic patronymics gets the patronymic rule too. A list of names with no common surname or given name carries no evidence and keeps the base, and moving the base takes from 5 names (Chinese, Korean, Czech) to 200 (Indian). See :ref:`suggest-settings`. :issue:`1308`
- **Fix the commas of Ethiopic, Burmese, N'Ko, Mongolian, Manchu, Lisu, Vai and Bamum, and the Ethiopic wordspace, which did not divide a name.** ``parse("ከበደ፣ አበበ")`` gives family ``ከበደ``, given ``አበበ``, where 1.4.0 through 3.0.1 gave given ``ከበደ፣``, family ``አበበ``; the other scripts' commas read the same way, every non-ASCII comma also divides the words of a bracketed credential as the ASCII one does, and ``አበበ፡ከበደ፡ተሰማ`` divides into three words at the wordspace ``፡``. :issue:`1202`
- **Fix a Mongolian case suffix joined by a narrow no-break space, which read as a word of its own.** ``Parser(policy=Policy(name_order=FAMILY_FIRST)).parse("ᠬᠣᠷᠯᠤ᠎ᠠ ᠶ᠋ᠢᠨ ᠴᠣᠢᠢᠪᠠᠯᠰᠠᠩ")`` gives family ``ᠬᠣᠷᠯᠤ᠎ᠠ ᠶ᠋ᠢᠨ``, given ``ᠴᠣᠢᠢᠪᠠᠯᠰᠠᠩ``, where 2.0.0 through 3.0.1 split at the U+202F and gave given ``ᠶ᠋ᠢᠨ``. 1.4.0, which has no name order, split there too, reading middle ``ᠶ᠋ᠢᠨ``. Elsewhere U+202F still divides like a space. :issue:`1236`
- **Fix the unbalanced-delimiter report on Dutch 't and 's, and read 's as part of the surname.** ``parse("Pieter 't Hart")`` and ``parse("Arent van 's-Gravesande")`` report nothing, where 2.0.0 through 3.0.1 reported ``unbalanced-delimiter``; ``Willem Jacob 's Gravesande`` gives family ``'s Gravesande``, where 1.4.0 through 3.0.1 gave middle ``Jacob 's``; and ``Jan van 't Hof 'Jantje'`` gives nickname ``Jantje`` as 1.4.0 did, where 2.0.0 through 3.0.1 gave ``t Hof 'Jantje``. :issue:`1241`
Expand Down
20 changes: 10 additions & 10 deletions docs/suggest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Settings for a list of names

A list of names is usually written in one convention: a registry gives
every family name first, a mailing list every family name last. A
single name cannot show which, because ``Priem Jason`` and ``Jason
Priem`` are the same shape and only a reader who knows ``Priem`` is a
surname and ``Jason`` a given name can tell them apart. A whole list
single name cannot show which, because ``Smith Mary`` and ``Mary
Smith`` are the same shape and only a reader who knows ``Smith`` is a
surname and ``Mary`` a given name can tell them apart. A whole list
can: most of its names carry some evidence, and the evidence agrees.

``Parser.suggest()`` reads a list you declare to be one group (one
Expand Down Expand Up @@ -46,17 +46,17 @@ votes do not decide keeps the base parser's value.
.. doctest::

>>> from nameparser import Parser
>>> listing = ["Priem Jason", "Kim Minjun", "Wang Xiaoming",
... "Nguyen Anh", "Jason Priem"]
>>> listing = ["Smith Mary", "Kim Minjun", "Wang Xiaoming",
... "Nguyen Anh", "Mary Smith"]
>>> suggestion = Parser().suggest(listing)
>>> suggestion.patch
PolicyPatch(name_order=FAMILY_FIRST)
>>> Parser().parse("Priem Jason").given
'Priem'
>>> suggestion.parser.parse("Priem Jason").given
'Jason'
>>> Parser().parse("Smith Mary").given
'Smith'
>>> suggestion.parser.parse("Smith Mary").given
'Mary'
>>> [entry.text for entry in suggestion.disagreeing()]
['Jason Priem']
['Mary Smith']

``suggestion.parser`` is the base parser with ``suggestion.patch``
applied, so the base is never changed. ``suggestion.evidence`` holds a
Expand Down
2 changes: 1 addition & 1 deletion nameparser/_suggest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ def _decide_order(tally: _Tally, base_order: tuple[Role, Role, Role],
def _texts(names: Iterable[str]) -> Iterator[str]:
"""The names, checked as they are consumed: one pass, so a
generator is read once."""
example = 'parser.suggest(["Priem Jason", "Kim Minjun"])'
example = 'parser.suggest(["Smith Mary", "Kim Minjun"])'
if isinstance(names, str):
raise TypeError(
f"suggest() takes an iterable of names, not a bare string: "
Expand Down
6 changes: 3 additions & 3 deletions tests/v2/test_reprs.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_policy_patch_repr_shows_only_set_fields() -> None:
Matching(Parser()),
Matching(parser_for(locales.ES)),
Matching(Parser(segmenter=functools.partial(_decline, blob="x" * 500))),
Parser().suggest(["Priem Jason", "Kim Minjun", "Jason Smith"]),
Parser().suggest(["Smith Mary", "Kim Minjun", "Jason Smith"]),
Parser().suggest([]),
])
def test_config_reprs_never_leak_the_unset_sentinel(obj: object) -> None:
Expand Down Expand Up @@ -214,10 +214,10 @@ def test_order_repr_survives_smuggled_setstate_values() -> None:

def test_suggestion_repr_shows_the_patch_and_counts_never_the_names(
) -> None:
s = Parser().suggest(["Priem Jason", "Kim Minjun", "Wang Xiaoming",
s = Parser().suggest(["Smith Mary", "Kim Minjun", "Wang Xiaoming",
"Jason Smith"])
assert repr(s) == ("Suggestion(PolicyPatch(name_order=FAMILY_FIRST), "
"names=4, disagreeing=1)")
for evidence in s.evidence:
for text in ("Priem", "Kim", "Smith"):
for text in ("Mary", "Kim", "Smith"):
assert text not in repr(evidence)
Loading
Loading