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.0.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.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: numbr-2.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 f70502c2f672ae450249a9f12b525ede9db3f8bbc65f67dfc6229e9a6fc2f234
MD5 8a4ee45301156e36b267aa94a1d1ddef
BLAKE2b-256 4c7403e01e7f4851d7767c29996815c48c00f9269d4d6556ac0141b665ef925c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: numbr-2.0.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 88d1a6c632936a57421b368852b6eb2b976666a017afea6843911ac461ddfad7
MD5 a548345dc9934eb2c9b9ba95a189bac1
BLAKE2b-256 7f10cb9d9f7417c82e2326f1269f72daf3a375d21bfa0a607f3f28352c8ba1ac

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