jaraco/inflect

singular_noun on word ending in "s" removes s.

eykamp opened this issue · 5 comments


import inflect as Inflect
inflect = Inflect.engine()
inflect.singular_noun("car")           # get False, as expected
inflect.singular_noun("mass")          # get "mas", expected False

Is this behavior a bug? singular_noun() is supposed to return False when the word is already singular, and I can find no reference to suggest "mass" is the plural of "mas", which is itself the plural of "ma".

This issue is related to #161. It seems inflect is naïve when it comes to many words and simply adds or subtracts a trailing s for plural/singular transforms. Probably there are many such edge cases.

I'd be open to a special-case fix for "mass" or a more general solution to words ending in "s".

I got the same error with two other words: loss (gave los) and analysis (gave analysi). For the first word its easy (and the same case as mass), don't remove the last s when word ends with double s, but the other one is more tricky.

@jaraco I can only think of a solution that involves a dictionary (like a list of valid words). That would be cumbersome, but I can't think of it in another way. One solution would be creating another repo with only a list of words (maybe only singulars?) like this one and then offer a version of the functions that loads this list (for people that don't mind loading a set of words in memory for the sake of correctness).

This would be helpful also when using specific terms, so it could have for example a set of words for specific scenarios, like machine learning, biology, etc.

@jaraco I'm pretty sure all words that end with ss are singular. If you think this is the right solution, can I correct this issue and submit a pull request?

eykamp commented