[ANN] inflect.py: generate plurals, ordinals, numbers to words...
Paul
pwdyson at yahoo.com
Thu Jul 15 13:00:53 CEST 2010
I'm pleased to announce the release of inflect.py v0.1.8, a module that correctly generates:
* the plural of singular nouns and verbs
* the singular of plural nouns
* ordinals
* indefinite articles
* present participles
* and converts numbers to words
Examples:
>>> import inflect
>>> p = inflect.engine()
>>> p.pl('cat')
'cats'
>>> p.pl('sheep')
'sheep'
>>> p.pl('bacterium')
'bacteria'
plural of singular verbs: it walks -> they walk
>>> p.pl('walks')
'walk'
singular of plural nouns:
>>> p.sinoun('bacteria')
'bacterium'
>>> p.sinoun('knives')
'knife'
ordinals:
>>> p.ordinal(31)
'31st'
>>> p.ordinal('twenty-five')
'twenty-fifth'
indefinite articles:
>>> p.a('horse')
'a horse'
>>> p.a('ant')
'an ant'
>>> p.a('hour')
'an hour'
present participles:
>>> p.prespart('drinks')
'drinking'
>>> p.prespart('runs')
'running'
>>> p.prespart('flies')
'flying'
numbers to words:
>>> p.numwords(1234567)
'one million, two hundred and thirty-four thousand, five hundred and sixty-seven'
Installation: "pip install inflect" or "easy_install inflect"
PyPi: http://pypi.python.org/pypi/inflect
Bug Tracker: http://github.com/pwdyson/inflect.py/issues
Source Code: http://github.com/pwdyson/inflect.py
Cheers,
Paul Dyson
More information about the Python-announce-list
mailing list