Skip to content

Fix particle rules falsely lowercasing apostrophe names#17

Open
shrinathaithal wants to merge 2 commits into
tenderlove:masterfrom
shrinathaithal:fix-apostrophe-name-particle-detection
Open

Fix particle rules falsely lowercasing apostrophe names#17
shrinathaithal wants to merge 2 commits into
tenderlove:masterfrom
shrinathaithal:fix-apostrophe-name-particle-detection

Conversation

@shrinathaithal
Copy link
Copy Markdown

Problem

Particle prefix rules (La, Le, Von, De, El, Ap, Bin, Dell[ae], D[aeiou'], D[ao]s, De[lr]) use \b word boundary anchors, which match at apostrophes. This causes names like La'Shea, Da'Quan, and Le'Andre to be incorrectly lowercased:

NameCase("la'shea")   # => "la'Shea"  (expected "La'Shea")
NameCase("da'quan")   # => "da'Quan"  (expected "Da'Quan")
NameCase("le'andre")  # => "le'Andre" (expected "Le'Andre")

The Al, Ben, and Van rules already avoid this by using (?=\s+\w) lookahead instead of \b.

Fix

Changed the remaining 9 particle rules to use (?=\s+\w), consistent with the existing pattern. Particles only function as particles when followed by a space and a surname — not before an apostrophe.

Before / After

Input Before After
la'shea la'Shea La'Shea
da'quan da'Quan Da'Quan
le'andre le'Andre Le'Andre
la poisson la Poisson la Poisson
von braun von Braun von Braun
del crond del Crond del Crond

All existing tests pass. Added test cases for apostrophe names.

Particle prefix rules (La, Le, Von, De, etc.) used \b which matches
at apostrophes, incorrectly lowercasing names like La'Shea to la'Shea,
Da'Quan to da'Quan, and Le'Andre to le'Andre.

Changed 9 rules to use (?=\s+\w) lookahead — matching the pattern
already used by Al, Ben, and Van rules. Particles only function as
particles when followed by a space and a surname, not before an
apostrophe.
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