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-1.0.0.tar.gz (16.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-1.0.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for numbr-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2bb3923e28ff6314744485bfe1ddf4798a2a0316167a071b571d332826b0af86
MD5 7a0891d2a8fbd6e3bc2f9fbd6317409a
BLAKE2b-256 8be67a37a8648c3b5f0ca0b596cf7370289621fc47b5f64d526fc8d40ff40c54

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for numbr-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 04b6927e9d23f38732ac1b1f4e7a9750e5530e89b5bf8b48a6ac8b891e07b16c
MD5 d70187fb5d2c46aa3827cae2ec879e02
BLAKE2b-256 62f2e66d90939035111555fd813c30c218c1127fb9f6ac5c86e84b3446872867

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