Skip to content

fix(#459): repair one-case suffix acronyms to all-caps in case repair - #521

Open
IMGillusion wants to merge 1 commit into
derek73:masterfrom
IMGillusion:fix/459-suffix-acronym-caps
Open

fix(#459): repair one-case suffix acronyms to all-caps in case repair#521
IMGillusion wants to merge 1 commit into
derek73:masterfrom
IMGillusion:fix/459-suffix-acronym-caps

Conversation

@IMGillusion

Copy link
Copy Markdown

What

HumanName('JOHN SMITH MBA').capitalize() returned 'John Smith Mba' — a credential acronym title-cased as an ordinary word (#459).

CAPITALIZATION_EXCEPTIONS only carries the five pieces that need non-all-caps spelling (md, phd, ii, iii, iv); every other suffix_acronyms entry fell through to str.capitalize() and got title-cased (mba -> Mba, jd -> Jd, qc -> Qc, mp -> Mp).

Fix

In _cap_word, after the exceptions-map lookup and before the Mac/Mc rule, a word whose period-free form is a known suffix_acronyms entry repairs to word.upper().

Gated on role is Role.SUFFIX so a word that is in the vocabulary but parsed as a family name (anh van do -> Anh Van Do) still repairs as an ordinary name word, not an acronym. The exceptions map is consulted first, so md -> M.D. and phd -> Ph.D. are unchanged.

Out of scope

The issue's QC MP example: the parser assigns QC the GIVEN role and MP the SUFFIX role, so only MP repairs to caps here. Uppercasing a word merely because it is a given name would break ordinary names that share a spelling with an acronym (e.g. ed -> ED), so the GIVEN case is left to the parser. Flagging it here rather than widening the gate.

Docs & tests

  • New examples in tests/test_capitalization.py (all-caps suffix, exceptions still win, family-name-in-vocab stays title-case).
  • rules.md R4: added a john smith mba example; regenerated tools/differential/corpus_rules.jsonl.

Full suite: 7610 passed, 179 skipped, 4 xfailed.

Gated on the SUFFIX role; exceptions map consulted first so md/phd keep their special casing. R4 example added; corpus regenerated.
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.

1 participant