Skip to content

fix(utils): keep dotted acronyms uppercase in str_title_case - #392

Open
Sanjays2402 wants to merge 2 commits into
jkwill87:mainfrom
Sanjays2402:fix/title-case-dotted-acronym
Open

Sanjays2402 wants to merge 2 commits into
jkwill87:mainfrom
Sanjays2402:fix/title-case-dotted-acronym

Conversation

@Sanjays2402

Copy link
Copy Markdown

Closes #297

str_title_case rendered S.W.A.T. as S.W.a.T. (and M.A.S.H. as M.a.S.H.): . is in padding_chars, so the single-letter lowercase exception a looked left- and right-partitioned like a standalone word. The lowercase transformation is now skipped when a one-letter exception is flanked by dots; multi-word titles are unchanged.

Regression test test_str_title_case__lower__dotted_acronym fails without the fix and passes with it; tests/local/test_utils.py is green (198 passed).

Titles like S.W.A.T. and M.A.S.H. were rendered as S.W.a.T. and M.a.S.H.
because the single-letter lowercase exception 'a' matched the acronym
component: '.' is a padding character, so the 'a' looked left- and
right-partitioned like a standalone word.

Skip the lowercase transformation when a single-letter exception is
flanked by dots. Multi-word titles are unaffected.

Adds a regression test covering S.W.A.T. and M.A.S.H.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: adcd5c4a08

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread mnamer/utils.py Outdated
Comment on lines +479 to +481
is_acronym_letter = (
word_length == 1 and prev_char == "." and next_char == "."
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve lowercase articles in dot-delimited titles

When periods are word separators rather than acronym punctuation, this condition misclassifies every internal a as an acronym component. For example, str_title_case("Once.Upon.a.Time") previously returned Once.Upon.a.Time but now returns Once.Upon.A.Time; these values flow through the movie and episode metadata setters into renamed paths. Distinguish a run of single-letter dotted components from an article merely surrounded by dot-delimited words.

Useful? React with 👍 / 👎.

@Sanjays2402

Copy link
Copy Markdown
Author

Good catch — confirmed that str_title_case("Once.Upon.a.Time") was coming out as "Once.Upon.A.Time" (verified before/after). Fixed in 7bbe870: a single letter between dots now only counts as an acronym component when it belongs to a run of single-letter dot-separated components (checked via the neighboring components, either side). So S.W.A.T./M.A.S.H. still stay uppercase, while Once.Upon.a.Time keeps its lowercase article. Added regression cases for dotted words to the parametrized test.

This branch has not been deployed

No deployments
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.

Incorrect capitalization

1 participant