Skip to content

Commit 9d42aaa

Browse files
derek73claude
andcommitted
Say what replace() actually carries over, and what it deliberately drops
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent f5c74e7 commit 9d42aaa

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

docs/usage.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,11 @@ Correcting a parse
401401
--------------------
402402

403403
:class:`~nameparser.ParsedName` is immutable, so a correction is a new
404-
value: ``replace()`` returns a copy with the given fields changed and
405-
everything else carried over.
404+
value: ``replace()`` returns a copy with the given fields changed.
405+
Untouched fields keep their tokens (and ``original`` is preserved),
406+
with one deliberate exception: an ambiguity that pointed into a
407+
replaced field is dropped — correcting the field that was flagged
408+
clears the flag, while correcting an unrelated field keeps it.
406409

407410
.. doctest::
408411

@@ -412,6 +415,11 @@ everything else carried over.
412415
'Dr. Juan de la Vega'
413416
>>> name.title
414417
''
418+
>>> flagged = parse("Van Buren")
419+
>>> flagged.replace(given="Martin").ambiguities
420+
()
421+
>>> [a.kind.value for a in flagged.replace(family="Harrison").ambiguities]
422+
['particle-or-given']
415423

416424
``replace()`` splits values on whitespace into plain, untagged
417425
tokens — the vocabulary knowledge a parse would have about the new

0 commit comments

Comments
 (0)