Skip to main content

Singularize or pluralize a given word using a pre-defined list of rules

Project description

PyPI Codecov GitHub Workflow Status PyPI - Downloads

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.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pluralizer-2.0.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

pluralizer-2.0.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file pluralizer-2.0.0.tar.gz.

File metadata

  • Download URL: pluralizer-2.0.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.12

File hashes

Hashes for pluralizer-2.0.0.tar.gz
Algorithm Hash digest
SHA256 3d48412c17397f52fb5b5485cbb5427b687d6e21daca0e65d9dfc16a989ec0c9
MD5 f095539233d687bcab749708f7ea9447
BLAKE2b-256 77b3bf7fe8341d5eb6b86f9b99d0419efe431b83be105db4d70646138fbadd30

See more details on using hashes here.

File details

Details for the file pluralizer-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: pluralizer-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.12

File hashes

Hashes for pluralizer-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 282e536f989cc30eeb4db69b63539030b2e50f1c93d737b783a924fe486d8141
MD5 7c5cfb8c3888b58e42e7255512725fb1
BLAKE2b-256 8eefac208cfa9d708d246aca64192fca9bd6518618998c4efa8e765ceac34405

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page