plurals / pluralize

Pluralize or singularize any word based on a count
MIT License
2.15k stars 184 forks source link

"Uncountables" fail when at end of phrase #205

Closed jegelstaff closed 1 month ago

jegelstaff commented 1 month ago

Hello, great library! I love that it handles multiple words, ie: "List of Houses", and it understands the singular would be "List of House" (even if that doesn't really make sense, but you get the idea).

However, something about the way the words are split up and passed through the process, fails when the last word is a word with no plural, ie: moose (the words added to the uncountable rule). As far as I can tell, this is due to the preceding space being included in the string?

ie: "Moose" works, but " Moose" when pluralized becomes " Mooses"

Similarly: "List of Moose" when pluralized becomes "List of Mooses" so it's as if the preceding space trips up the identification of the word as uncountable?

Irregular singular/plurals work, ie: "List of Mouse" when pluralized become "List of Mice"

Thank you!

blakeembrey commented 1 month ago

Unfortunately handling multiple words are not an intentional part of the API, and I wouldn't recommend relying it. It works because most replacements are regular expressions targeting a number of different words with one replacement (e.g. houses, courses, etc).

So I don't think this library should try to handle that in uncountables either, it's a bit of a can of worms since once you start working with phrases it's possible the last word isn't even on the that should be altered.

jegelstaff commented 1 month ago

Good to know! Glad it works at least in part.