Skip to content

Normalize a possessive all-caps word in ToTitleCase the same as the word alone [patch] - #92

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/title-case-possessive-acronym
Sep 28, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/title-case-possessive-acronym

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #90

What was wrong

LowercaseAllCapsWords counts an apostrophe and the letters after it as part of the word. The lowercase s in CEO's therefore made the word mixed case, so it was skipped, and TextInfo.ToTitleCase kept CEO as an acronym. "the CEO office" gave The Ceo Office, but "the CEO's office" gave The CEO's Office. That is the kind of neighbour-dependent inconsistency that #72 set out to remove.

Change

A word is now judged all caps by its stem: the letters before its first in-word apostrophe, found with the existing IsApostropheWithinWord. If the stem is all caps, the whole word is lowercased, and TextInfo.ToTitleCase then gives Ceo's. A word with no in-word apostrophe is judged exactly as before. A leading or trailing apostrophe, such as a quote mark, is not in-word, so it does not change the stem.

Tests

ToTitleCaseShouldNormalizeAPossessiveAllCapsWordLikeTheWordAlone:

  • "the CEO office" → The Ceo Office (reference row)
  • "the CEO's office" → The Ceo's Office
  • "NASA's mission" → Nasa's Mission
  • "O'Neil" → O'neil (unchanged behaviour)

With CaseConverter.cs reverted, the CEO's and NASA's rows fail. With the change, all 69 tests pass on net10.0, and the solution builds for every target with 0 warnings.

The ’s (U+2019) form of this also needs #89's fix, which is in #91. That is why this PR has no U+2019 row: the two PRs stand alone and can merge in either order.

🤖 Generated with Claude Code

https://claude.ai/code/session_01N3tMVtLPuNwsQF7rUEBTMQ


Generated by Claude Code

…ord alone [patch]

LowercaseAllCapsWords judged a word by all its letters, so the lowercase "s"
of "CEO's" made it mixed case and it was preserved as an acronym, while "CEO"
on its own was normalized. Judge a word by the letters before its first
in-word apostrophe instead.

Fixes #90

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N3tMVtLPuNwsQF7rUEBTMQ
@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

Development

Successfully merging this pull request may close these issues.

ToTitleCase leaves an all-caps word unnormalized when it has a possessive: "CEO" -> "Ceo" but "CEO's" -> "CEO's"

2 participants