ppannuto / python-titlecase

Python library to capitalize strings as specified by the New York Times Manual of Style
MIT License
244 stars 36 forks source link

Should titlecase("CORPORATIONS - Continued") return the string unchanged? #92

Closed dogweather closed 12 months ago

dogweather commented 12 months ago

That's what I'm getting. I looked through the tests and I couldn't find one that documented this behavior. Is it by design?

>>> titlecase("CORPORATIONS - Continued")
"CORPORATIONS - Continued"

Huh. This happens too. If the first word is all caps, it's preserving it?

>>> titlecase("CORPORATIONS Continued")
"CORPORATIONS Continued"

Ok, no — now my theory is that it's incorrectly recognizing it as an initialism or acronym. I can't locate this logic in the code, but my theory is that this is an all-caps word in a string that's not all caps:

>>> titlecase("Continued CORPORATIONS")
"Continued CORPORATIONS"
ppannuto commented 12 months ago

but my theory is that this is an all-caps word in a string that's not all caps

Correct. If there is an all-caps word in a mixed-case text input, it is assumed that the all-caps is intentional. This is by design.

dogweather commented 12 months ago

Correct. If there is an all-caps word in a mixed-case text input, it is assumed that the all-caps is intentional. This is by design.

Thanks! In my input set I know that the all-caps words aren't acronyms, so I can work around this by converting to lower case before titlecase().