Quote:
Originally Posted by KevinH
No. You must have either not created the force_titlecase function properly or ran my force_titlecase function with your modified titlecase.py.
Notice the call to replace_titlecase in the force_titlecase uses new_match which was created by lowercasing everything first.
With stock titlecase.py for all of your testcases with my force_titlecase function, all of them convert to "Down the Rabbit-Hole" as expected. I just double-checked that.
Since they are lowercased first then all_caps must be false and no exceptions are handled. In your modified version it still will leave individual words that are ALL caps alone. That is not forcing titlecase.
That is why that titlecase.py stock, is correct as it was. It properly handles the case of the entire title being in all caps, which should be left alone. Your change invalidates that.
Please retry with the exact force_titlecase python function replace (copy and pasted from earlier to prevent errors) and stock titlecase.py (before any of your changes).
I did just that and all your test cases work.
|
The results I posted are with the stock titlecase function. The stock titlecase function does not preserve strings that are all caps, but it does preserve words that are all caps if there are any lower case letters in the string. If you look at the code from titlecase.py, you can see that if the string has no lowercase characters then it sets each word to lowercase unless UC_INITIALS.match(word) is true and then applies the titlecase algorithm to them.
A snippet of code from line 61 of titlecase.py
Code:
if all_caps:
if UC_INITIALS.match(word):
line.append(word)
continue
else:
word = toLower(word)