Skip to main content

A comprehensive Python library for parsing and converting numbers between numeric, word, and ordinal formats.

Project description

numbr

numbr is a Python library designed for parsing and converting numbers written in English. It simplifies working with numbers by converting between spelled-out forms, ordinal forms, and numeric representations.


Key Features

  • Convert spelled-out cardinal numbers into integers (e.g., "one hundred twenty-three"123).
  • Convert integers into their spelled-out English words (e.g., 123"one hundred twenty-three").
  • Convert ordinal words to numeric ordinals (e.g., "twenty-first""21st" or 21).
  • Extract numeric values from text strings.
  • Handle negative numbers, hyphenated numbers, and large numbers (up to quintillions).

Installation

Install numbr using pip:

pip install numbr

Usage Examples

Convert Words to Integer

import numbr

print(numbr.wordsToInt("one thousand two hundred thirty-four"))
# Output: 1234

Convert Integer to Words

print(numbr.intToWords(5678))
# Output: "five thousand six hundred seventy-eight"

Convert Ordinal Words to Numeric Form

print(numbr.ordinalWordsToInt("forty-second"))
# Output: "42nd"

print(numbr.ordinalWordsToInt("forty-second", to_num=True))
# Output: 42

Extract Numeric Values from Strings

print(numbr.extractNumericValue("I have twenty apples and 13 oranges."))
# Output: 20

Terminology

  • Cardinal Numbers: Represent quantity (e.g., "one", "twenty-five", "1,234").
  • Ordinal Numbers: Represent position or order (e.g., "first", "twenty-first", "3rd").
  • Ordinal Suffix: Letters added to numbers indicating position ("st", "nd", "rd", "th").

License

This project is licensed under the MIT License. See the LICENSE file for details.


Contributing

Contributions are welcome! Feel free to open issues or submit pull requests to improve numbr.


Contact

For questions or feedback, please open an issue on the project's GitHub repository.

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

numbr-2.0.1.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

numbr-2.0.1-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file numbr-2.0.1.tar.gz.

File metadata

  • Download URL: numbr-2.0.1.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.8.5

File hashes

Hashes for numbr-2.0.1.tar.gz
Algorithm Hash digest
SHA256 a190f33256a30e6b8c33b794fd2e9acbbd2beea2dd562db1cfb1a70799369531
MD5 756980d85daff9dca80f426e683a5a85
BLAKE2b-256 34f2cab732eedd536aa4bd19d68472da7bbafc11f001cef4f8b1f43f89c261be

See more details on using hashes here.

File details

Details for the file numbr-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: numbr-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.8.5

File hashes

Hashes for numbr-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3d253f785586b0e897b0a1937b16690477d07b032da8f7ca24a3d85b34abcd75
MD5 a9499e48d3f9abc4cf343ab5a806a8ce
BLAKE2b-256 a0aa97ad84d32d9d1d0fb06cdf9a42a38b41ce3303505a6960bc486eaf82d0f0

See more details on using hashes here.

Supported by

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