inflect icon indicating copy to clipboard operation
inflect copied to clipboard

Undocumented `False` for `singular_noun` if word is already singular

Open AlexeySanko opened this issue 7 years ago • 7 comments

>>> word = 'woman'
>>> word = p.plural_noun(word)
>>> word
'women'
>>> word = p.plural_noun(word)
>>> word
'womens'

AlexeySanko avatar Feb 15 '19 19:02 AlexeySanko

I think this is intended behaviour, as this module is garbage, in garbage out.

The method plural_noun() takes a singular English noun or pronoun and returns its plural.

https://github.com/jazzband/inflect#forming-plurals-and-singulars

Only the first case provides a singular noun.

hugovk avatar Feb 15 '19 19:02 hugovk

Hi, @hakubo Is it possible to check that work is plural? As I understand it's different logic with singular_noun which returns False for singular nouns....

AlexeySanko avatar Feb 15 '19 19:02 AlexeySanko

Yes:

The method singular_noun() takes a plural English noun or pronoun and returns its singular.

Or otherwise False:

>>> import inflect
>>> p = inflect.engine()
>>> p.singular_noun('women')
'woman'
>>> p.singular_noun('woman')
False

hugovk avatar Feb 15 '19 19:02 hugovk

But into documentation is nothing about this difference.

And as I understand correct way of plural_noun usage is (because we do not have is_plural function:

import inflect
p = inflect.engine()
word = 'women'
p.plural_noun(word) if not p.singular_noun(word) else word

AlexeySanko avatar Feb 15 '19 20:02 AlexeySanko

That's a good point about it not being documented, because now you mention it, GIGO also applies to singular_noun.

For example (https://github.com/jazzband/inflect/issues/4#issuecomment-1083243):

>>> import inflect
>>> p = inflect.engine()
>>> p.singular_noun('woman')
False
>>> p.singular_noun('dress')
'dres'

Inflecting Plurals and Singulars

All of the plural... plural inflection methods take the word to be inflected as their first argument and return the corresponding inflection. Note that all such methods expect the singular form of the word. The results of passing a plural form are undefined (and unlikely to be correct). Similarly, the si... singular inflection method expects the plural form of the word.

https://github.com/jazzband/inflect#inflecting-plurals-and-singulars

So you need to know what sort of input you give and use the correct method. You can throw anything in and hope for the best but it's not the intended use and you might well get something undefined out.

hugovk avatar Feb 15 '19 20:02 hugovk

I changed title of issue. Thank You, @hugovk !

AlexeySanko avatar Feb 15 '19 20:02 AlexeySanko

I think False should remain undocumented because it can't be relied upon to determine singular/plural.

hugovk avatar Feb 15 '19 20:02 hugovk