Skip to content

Conversation

@katerinachinnappan
Copy link
Contributor

@katerinachinnappan katerinachinnappan commented Nov 2, 2024

Goal

Fix the capitalization rules for english titles:

  • Capitalize the word "so" (remove as a stop word)
  • Capitalize the first word (regardless if it is a stop word) after a quote: 'the day' -> 'The Day'
  • Ensure there is a difference between a quote and apostrophe: 'the day' day'S -> 'The Day' Day's
  • Capitalize word after a colon (:): 'the day' day's: day -> 'The Day' Day's: Day

Final result: Amorim aims to 'prove something' at Manchester United after agreeing deal: read the day's 'news' -> Amorim Aims to ‘Prove Something’ at Manchester United After Agreeing Deal: Read the Day’s ‘News’

Todos

  • deploy to dev

Reference

Tickets:

@katerinachinnappan katerinachinnappan requested a review from a team as a code owner November 2, 2024 12:06
Copy link
Collaborator

@jpetto jpetto left a comment

Choose a reason for hiding this comment

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

functionally this looks great - hoping we can add some comments and targeted unit tests 😄

// Boolean here acts as a callback, evaluates each word:
// If it's a non-empty string, keep the word in the array;
// If it's an empty string (or falsy), remove from array.
const allWords = value.split(SEPARATORS).filter(Boolean); // Split and filter empty strings
Copy link
Collaborator

Choose a reason for hiding this comment

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

just out of curiosity, what is the filter(Boolean) guarding against?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

filter(Boolean) removes any false values like NaN, undefined, etc

Copy link
Collaborator

Choose a reason for hiding this comment

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

but could those values ever appear in a split string? doesn't hurt to have it in, just wondering if you came across a case where something falsy ended up in the array. 😅

Copy link
Collaborator

@jpetto jpetto left a comment

Choose a reason for hiding this comment

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

great work, and love the comments and tests!

@katerinachinnappan katerinachinnappan merged commit 7d4c610 into main Nov 5, 2024
2 checks passed
@katerinachinnappan katerinachinnappan deleted the katerina/MC-1583-fix-title-english branch November 5, 2024 17:34
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.

3 participants