jaraco / inflect

Correctly generate plurals, ordinals, indefinite articles; convert numbers to words
https://pypi.org/project/inflect
MIT License
957 stars 107 forks source link

Capitalized words are not inflected #201

Open mmlange opened 1 year ago

mmlange commented 1 year ago

Found a strange issue when trying to retrieve the plural of property, using either plural() or plural_noun():

Python 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)] on win32

>>> import inflect
>>> p = inflect.engine()

>>> p.plural('property')
'properties'

>>> p.plural('Property')
'Propertys'

I looked through the documentation, but didn't see any notes about why this would be.

I think the plural of property, whether capitalized or not, should be properties.

jaraco commented 5 months ago

It's not obvious to me whether the behavior you expect is desirable or not. I can definitely see how in some cases you would want to inflect a capitalized word. Other times, the word might be part of a title or proper name and shouldn't be pluralized.

I thought I'd check, and it seems the library does seem to treat title case differently:

>>> p.singular_noun('Nine Inch Nails')
'Nine Inch Nail'
>>> p.plural('Nine Inch Nail')
'Nine Inch Nails'

My guess is that inflect would need to do some case-insensitive matching if it were to implement handling words in title case. I don't know what other assumptions might be violated.

I welcome contributions on this issue.