Skip to content

Don't capitalize Mr, Ms, Mrs#67

Merged
ppannuto merged 6 commits into
ppannuto:mainfrom
GurraB:mr-no-caps
Jul 20, 2020
Merged

Don't capitalize Mr, Ms, Mrs#67
ppannuto merged 6 commits into
ppannuto:mainfrom
GurraB:mr-no-caps

Conversation

@GurraB
Copy link
Copy Markdown
Contributor

@GurraB GurraB commented Jul 10, 2020

The current version will capitalize Mr, Mrs, Ms. I added a regex and an if-statement to handle them separately.

Previous
Mr Mrs Ms -> MR MRS MS

Now
Mr Mrs Ms -> Mr Mrs Ms

@coveralls
Copy link
Copy Markdown

coveralls commented Jul 10, 2020

Coverage Status

Coverage increased (+0.6%) to 81.773% when pulling bc90854 on GurraB:mr-no-caps into 0a1d1f6 on ppannuto:main.

Copy link
Copy Markdown
Owner

@ppannuto ppannuto left a comment

Choose a reason for hiding this comment

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

I've started trying to group these tests a bit more logically; does this change make sense / look good to you?

Comment thread titlecase/tests.py
@GurraB
Copy link
Copy Markdown
Contributor Author

GurraB commented Jul 10, 2020

So the and was made uppercase when using a dot. I'm guessing it's treated as a new sentence. The word after Mr, Mrs or Ms should always be uppercase I suppose. Do you think I should add that we uppercase the first char in the next word automatically when the word is Mr, Mrs or Ms even if there is not a dot?

@GurraB GurraB requested a review from ppannuto July 10, 2020 17:32
@ppannuto
Copy link
Copy Markdown
Owner

Ugh, this is what is unfortunate about a regex-based approach, you keep running into corner cases. From a quick survey of style guides online, everything after a Mr/Mrs/Dr should be capitalized except and.

If you want to add a special case so the library handles it correctly, that'd be awesome. If you'd rather just change the test to not include an and case it would just be return to what it was already doing anyway, so no regression, and would be fine with me.

@GurraB
Copy link
Copy Markdown
Contributor Author

GurraB commented Jul 16, 2020

I can't figure out a smart way to add exception for and without butchering the code. I'm fine with it as is now, let me know if you changed your mind and want changes.

Copy link
Copy Markdown
Owner

@ppannuto ppannuto left a comment

Choose a reason for hiding this comment

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

I think this is good, thanks for the updates. The reality is that a regex-based solution will always have some corner cases and imperfections that it misses.

@ppannuto ppannuto merged commit ad696e6 into ppannuto:main Jul 20, 2020
ppannuto added a commit that referenced this pull request Jan 22, 2021
Major (interface) changes (#60) -- big thanks @iburago!!:
 - Read from an abbreviations file only when invoked from command line
 - Rename and refactor the create_wordlist_filter() function

Minor changes:
 - #63: Do not capitalize small words occurring within hyphenated word groups (thanks @iburago!)
 - #65: Always capitalize 'Mc'-prefixed small words in compound word groups (thanks @iburago!)
 - #67: Don't capitalize Mr, Ms, Mrs (thanks @GurraB!)
 - #71: Add Manifest.in and include license file in src dist (thanks @synapticarbors!)
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