nbubna / Case

String case utitility: convert, identify, flip, extend
http://nbubna.github.io/Case/
MIT License
282 stars 23 forks source link

Sentence case can contain capitalization #22

Closed hubgit closed 7 years ago

hubgit commented 7 years ago

As well as the first letter, sentence case strings can contain capital letters in cases such as proper nouns and acronyms.

For example, this title should be identified as sentence case: "Skin microbiota in frogs from the Brazilian Atlantic Forest: species, forest type, and potential against pathogens".

nbubna commented 7 years ago

Yes, that's why Case.sentence takes two arguments. The first is the string to be case-corrected, the second is an array of proper names to be capitalized. Is that not working?

Obviously, i can't embed every possible proper name into this library. I see no other way to do it.

hubgit commented 7 years ago

In this instance I'm using Case.of to detect the case of a string to verify that it's sentence case, and I think Case.of doesn't take any extra arguments.

Perhaps the test could allow up to a certain percentage of words to be capitalised?

If not, no worries - I can use a bespoke function for this test.

nbubna commented 7 years ago

Ah, Case.of makes more sense. It might not be hard to add support for the second argument. Percentage capitalized, on the other hand, might be awkward to implement given the way i've built Case with regexps. I'll think on this. Seems like the 2nd argument should at least be supported.