Why this project?
This repo is simply a Python port of https://github.com/blakeembrey/pluralize which has > 1.4m github usages and 3.5 million downloads per week when I evaluating different libraries.
This module uses a pre-defined list of rules, applied in order, to singularize or pluralize a given word. There are many cases where this is useful, such as any automation based on user input. For applications where the word(s) are known ahead of time, you can use a simple ternary (or function) which would be a much lighter alternative.
I have compared the following alternatives and found https://github.com/blakeembrey/pluralize is the best one for me (most accurate), so ported it into the Python world.
- TextBlob: https://github.com/sloria/TextBlob
- inflect: https://github.com/jazzband/inflect
- NLTK Wordnet: https://www.nltk.org/howto/wordnet.html
Installation
pip install pluralizer
Usage
from pluralizer import Pluralizer
pluralizer = Pluralizer()
assert pluralizer.pluralize('apple', 1, False) == 'apple'
assert pluralizer.pluralize('apple', 1, True) == '1 apple'
assert pluralizer.pluralize('apple', 2, False) == 'apples'
assert pluralizer.pluralize('apple', 2, True) == '2 apples'
assert pluralizer.plural('apple') == 'apples'
assert pluralizer.singular('apples') == 'apple'
assert pluralizer.isPlural('apples') == True
assert pluralizer.isPlural('apple') == False
assert pluralizer.isSingular('apples') == False
assert pluralizer.isSingular('apple') == True
License
MIT
All credits to https://github.com/blakeembrey/pluralize.
Metadata
Release files for pluralizer 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pluralizer-2.0.0.tar.gz | 13.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pluralizer-2.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.3 kB
Release files / pluralizer-2.0.0.tar.gz
| Download URL | pluralizer-2.0.0.tar.gz |
|---|---|
| Size | 13.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3d48412c17397f52fb5b5485cbb5427b687d6e21daca0e65d9dfc16a989ec0c9
|
|
BLAKE2b-256 checksum How to use checksums |
77b3bf7fe8341d5eb6b86f9b99d0419efe431b83be105db4d70646138fbadd30
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.12
|
Release files / pluralizer-2.0.0-py3-none-any.whl
| Download URL | pluralizer-2.0.0-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
282e536f989cc30eeb4db69b63539030b2e50f1c93d737b783a924fe486d8141
|
|
BLAKE2b-256 checksum How to use checksums |
8eefac208cfa9d708d246aca64192fca9bd6518618998c4efa8e765ceac34405
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.12
|
Security for pluralizer 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.