Skip to content

Preserve lowercase particles in two-word names - #627

Open
natesute wants to merge 3 commits into
sciunto-org:mainfrom
natesute:fix/two-word-name-particles
Open

natesute wants to merge 3 commits into
sciunto-org:mainfrom
natesute:fix/two-word-name-particles

Conversation

@natesute

@natesute natesute commented Sep 30, 2026 •

Copy link
Copy Markdown

Fixes #626.

The two-word shortcut assumes the first token is a first name, so rewriting de Gaulle and van Gogh in last-name-first style produces Gaulle, de and Gogh, van. Use the case-aware partitioning for two-word names, and fix the case detection gaps this exposes for braced given names.

Recognize BibTeX's uppercase and lowercase letter commands, preserve special-character handling through nested accent braces, and ignore escapes inside ordinary protected groups. This keeps names such as {\L}ukasz Chmielewski, {\O}yvind Ytrehus, {\'{E}}ric Brier, and {Jean-Fran\c{c}ois} Biasse in first/last form. Shared parser and inverse tests cover these cases, lowercase controls, unknown commands, and nested/protected groups. End-to-end parse/write/parse tests preserve both the parts and the LaTeX spelling.

Validation:

  • 21 original regression cases and 66 additional case-detection regressions reproduced before their respective fixes.
  • pytest -q: 2,914 passed, 12 skipped.
  • pre-commit run --all-files: all hooks passed.
  • 156 targeted name/form combinations matched BibTeX 0.99d (format.name$), using the repository's parsename.bst helper.

The maintainer's merge of the TOML formatting fix is preserved.

@MiWeiss

MiWeiss commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Thanks! The fix for de Gaulle / van Gogh is correct and matches BibTeX.

One problem: the two-word shortcut was also hiding gaps in how we detect a word's case. Removing it exposes them for the most common name shape. These now parse as von + last instead of first + last:

parse_single_name_into_parts(r"{\L}ukasz Chmielewski")
parse_single_name_into_parts(r"{\O}yvind Ytrehus")
parse_single_name_into_parts(r"{\'{E}}ric Brier")           # nested accent, dblp style
parse_single_name_into_parts(r"{Jean-Fran\c{c}ois} Biasse")

BibTeX treats all four as first + last, for three reasons:

  • It counts \L, \O, \AA, \AE and \OE as uppercase.
  • It reads the letter inside nested braces like {\'{E}}.
  • It never treats a brace group that doesn't start with \ as von.

On cryptobib, 47 names change: 31 regress like the examples above, and 16 are lowercase given names that now follow BibTeX. Performance is unchanged.

Could you fix the case detection for these shapes in this PR and add them to the test cases?

@drkotireddysaripalli

Copy link
Copy Markdown

I traced the exact helper at head c81c6e0 using its extracted NameParts and parser definitions. All four requested names reach the split with word cases [0, 1] and become von + last; the seven shared cases added here still pass.

The trace narrows the case repair to three paths:

  • {\L} / {\O}: the leading escape branch marks a control sequence without assigning case. The following unbraced u / y then assigns lowercase.
  • {\'{E}}: opening the nested brace clears specialchar, so the E never supplies case; the later r does.
  • {Jean-Fran\c{c}ois}: the escape-case elif at lines307–311 assigns lowercase from command c while level == 1 and specialchar == False, inside the protected group.

These are useful separate regression targets alongside the particle controls. I ran the source-extracted helper, not BibTeX or the full parser/writer pipeline; the expected first/last results come from your request.

Affiliation: Chief Scientist PinnacleAI(R), Pinnacle Blooms Network of Bharath Healthcare P LIMITED, https://www.pinnacleblooms.org/verify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SplitNameParts: two-word names like "van Gogh" or "de Gaulle" put the particle in first instead of von

3 participants