镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Should a bare 'И' parse as an initial or the conjunction 'and'? (e.g. 'Хосе И Мария Сантос') #267

Description

@derek73

The initial regex is ^(\w\.|[A-Z])?$ (nameparser/config/regexes.py). The dotted branch is Unicode-aware (\w), so И. is recognized as an initial — but the bare-letter branch is ASCII [A-Z], so bare E is an initial while bare И is not.

With default constants this has no visible effect. It surfaces as soon as non-Latin conjunctions are configured (see the non-Latin constants proposal), because is_an_initial() is the veto that stops a single capital letter from being treated as a conjunction:

>>> from nameparser import HumanName
>>> from nameparser.config import Constants

>>> HumanName("Jose E Maria Santos").first   # 'e' is a built-in conjunction;
'Jose'                                        # bare 'E' vetoed as initial -> middle 'E Maria'

>>> C = Constants()
>>> C.conjunctions.add('и')                   # Cyrillic 'and'
>>> HumanName("Хосе И Мария Сантос", constants=C).first
'Хосе И Мария'                                # bare 'И' NOT an initial -> conjunction joins

The open question is which behavior is right. The bare-capital-initial convention ("John F Kennedy") is largely an English/Latin habit; Russian typography virtually always writes initials with periods (И. С. Петров), so treating a bare И as a conjunction is arguably correct for Cyrillic. Options:

  1. Change the default: make the bare-letter branch Unicode-uppercase-aware so the initial veto is consistent across scripts. Downside: blocks single-letter non-Latin conjunctions by default, and bare initials without periods are rare outside English anyway.

  2. Keep the default and document the override. regexes.initial is editable config like everything else; users who want Latin-style veto behavior for Cyrillic can use:

    C.regexes.initial = re.compile(r'^(\w\.|[A-ZА-ЯЁ])?$')

    Note the override must be script-targeted — widening the bare branch to any Unicode letter would also match lowercase e and silently disable the built-in Latin conjunction.

Verified on v1.3.0. Related: the non-Latin constants proposal #269, #265, #266.

Activity

  1. changed the title [-]Bare-letter branch of the 'initial' regex is ASCII-only — script asymmetry in the initial veto[/-] [+]Should a bare 'И' parse as an initial or the conjunction 'and'? (e.g. 'Хосе И Мария Сантос')[/+] on Jul 7, 2026
  2. l1asis commented on Jul 29, 2026

    @l1asis

    Treating the bare letter as a conjunction is definitely the correct approach for Cyrillic.

    In Russian, it is и and in Ukrainian, it is either і or й. A bare и or і or й is almost always a conjunction. Standard Cyrillic typography strictly requires periods for initials (e.g., И. Иванов, І. Франко).

    Great real-world examples of this are:

    • Russian: "А. П. и Е. Н. Ивановы"
    • Ukrainian: "Олесь і Олена Коваленки"

    In these examples:

    • и and і are conjunctions.
    • A. П., Е. Н. are correctly punctuated initials.
    • Олесь, Олена are first names.
    • Ивановы and Коваленки are plural family names. The correct singular base forms for the individuals would be Иванов (m) and Иванова (f) or Коваленко (m+f).
  3. derek73 commented on Jul 30, 2026

    @derek73
    OwnerAuthor

    Thanks for the reply. v2.0 of the parser behaves this way by default. Just wanted someone to verify that it was the right call. Thanks!

    >>> parse("Хосе И Мария Сантос")
    <ParsedName: [
        given: 'Хосе И Мария'
        family: 'Сантос'
    ]>
  4. added a commit that references this issue on Jul 31, 2026
  5. added this to the v2.1 milestone on Aug 6, 2026
  6. self-assigned this
    on Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions