Skip to content

Keep an all-caps possessive after a lowercased capital run in its word [patch] - #153

Open
matt-edmondson wants to merge 1 commit into
mainfrom
fix/all-caps-possessive-after-lowercased-run
Open

matt-edmondson wants to merge 1 commit into
mainfrom
fix/all-caps-possessive-after-lowercased-run

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #148

What changed

In the apostrophe branch of ReplaceNonAlphaNumericWithSpace, lowercaseSuffix is now computed as the issue suggests:

lowercaseSuffix = (lowercaseSuffix && AreLettersFromIndexUppercase(input, nextStart))
    || IsCapitalRunAfterLowercaseLetter(input, previousLetterStart, nextStart);

The run before a second apostrophe (NEIL in o'NEIL'S) is already being lowercased, so it now counts as lowercase. The all-caps suffix after it is lowercased too, rather than leaving oneilS for SplitOnCaseChange to split. lowercaseNextLetter needed no change: a letter is lowercased when either flag is set, so the corrected lowercaseSuffix covers it.

Tests

New rows in ApostropheWithinWordShouldNotSplitIt (Pascal, camel, snake, kebab and macro):

  • o'NEIL'S and o’NEIL’S → oneils
  • d'ARTAGNAN'S sword → dartagnans_sword
  • l'API'S → lapis
  • O'NEIL'S → oneils (control)

With the fix reverted, the first four fail. With it, the full suite passes on net10.0, including the existing #88, #128 and #135 rows.

Per the triage note, this may conflict textually with #146, which changes nearby apostrophe handling.


Generated by Claude Code

…d [patch]

In "o'NEIL'S" the run "NEIL" is lowercased because it follows a lowercase
letter, but at the second apostrophe lowercaseSuffix was recomputed from the
original input, where the letter before it is the capital "L". The "S" stayed
uppercase, so "oneilS" split into "oneil S". A run that is already being
lowercased now counts as lowercase for the suffix after it.

Fixes #148

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW6QSBbC4yjv9GxYCN1
@sonarqubecloud

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

2 participants