Inflect.py is a Python library designed to correctly generate plurals, singular nouns, ordinals, indefinite articles (a/an), and word-based representations of numbers. Its functionality is primarily focused on the English language. As of version 7.5.0, it maintains an active development and release cadence, with regular updates addressing features, bug fixes, and compatibility.
pip install inflectVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates common `inflect` functionalities: pluralizing nouns conditionally, generating ordinal numbers, converting numerals to words, and selecting indefinite articles ('a' or 'an').
Refer to the `inflect` documentation for current method names and update your code accordingly. These typically involve methods for singular/plural inflection.
Always provide the correct base form (singular for pluralization, plural for singularization) to the respective `inflect.engine()` methods.
Upgrade `inflect` to the latest v7.x version. If issues persist, ensure your environment's Pydantic (if present) and `inflect` versions are compatible, or isolate `inflect` in a separate virtual environment.
Consider using `print(p.inflect('num({0}) plural_noun(error) plural_verb(was) detected.'.format(errors)))` instead of `print(p.num(errors), p.plural_noun(' error'), p.plural_verb(' was'), ' detected.')`.pip install inflect
Upgrade 'inflect' to the latest version (7.2.0 or higher) using `pip install --upgrade inflect`, or downgrade Pydantic to a 1.x version using `pip install 'pydantic<2'`.
Always provide the correct base form (singular for pluralization, plural for singularization) to the respective `inflect.engine()` methods. For example, use `p.plural('cat')` for pluralizing 'cat' and `p.singular_noun('people')` for singularizing 'people'.import inflect
p = inflect.engine()
word = p.plural("cat")import inflect
p = inflect.engine()
# Configuration options are set on the engine instance, e.g.:
p.classical(all=False)
p.no("and")