numbr
A lightweight NLP-focused Python toolkit for recognising, parsing, and transforming numbers expressed in natural-language or symbolic form.
It handles everything from “forty-two” → 42 to “Ⅳ” → “fourth” in a single call.
✨ Key capabilities
| Task | Example in | Example out | Function |
|---|---|---|---|
| Spell-out → digits | "one hundred sixty-seven" |
167 |
wordsToInt |
| Digits → words | 19007 |
"nineteen thousand seven" |
intToWords |
| Any form → type detection | "3rd" |
"Ordinal Number" |
Type |
| Cross-form casting | "third" → "3" |
"third" |
Cast("third", "Cardinal Number") |
| Roman → integer | "MCMXCIV" |
1994 |
romanToInt |
| Batch extraction | "He scored twenty-one of 34 attempts" |
[21, 34] |
extractNumericValue |
(full API listed below)
🔧 Installation
pip install numbr
# or install from source
pip install git+https://github.com/cedricmoorejr/numbr.git
🚀 Quick start
import numbr
numbr.Type("forty-ninth")
# → 'Ordinal Word'
numbr.Cast("forty-ninth", target="Ordinal Number")
# → '49th'
numbr.Cast(512, target="Ordinal Word")
# → 'five hundred twelve th'
🧰 Public API Overview
numbr exposes a clean, top-level API designed for simplicity and readability.
All functions listed below are available directly via:
import numbr
numbr.Type("twenty-first")
numbr.Cast("Ⅳ", target="Ordinal Word")
No internal modules need to be accessed directly — everything is exposed at the package root.
1. High-Level Helpers
| Helper | Purpose |
|---|---|
Type(value) |
Detect and return the representation category of value — e.g., "Cardinal Word", "Ordinal Number", etc. |
Cast(value, target, *, as_str=False) |
Convert value to a target representation and optionally return it as a string. |
2. Core Conversion Functions
These functions handle numeric parsing, word formatting, Roman numeral conversion, and formatting:
wordsToInt,ordinalWordsToInt,stringToIntintToWords,intToOrdinalWordsordinalSuffix,stripOrdinalSuffixromanToInt,romanToWordsinsertSep,formatDecimal,extractNumericValue
3. Cross-Type Shorthands
These helpers provide direct one-step conversions between common forms:
cardinalWordToOrdinalNumordinalNumToCardinalWordordinalWordToCardinalNum- ...and many more.
Use these when you know the source and target types and want to avoid an intermediate call to Cast.
📝 Roadmap
- Locale & language plugins (FR, DE…)
- Currency-aware formatting
- CLI utility
📄 License
This project is licensed under the MIT License. See the LICENSE file for details.
🙌 Contributing
Issues, pull-requests and feature ideas are very welcome to improve numbr!
Clone the repo, create a branch, add tests, and open a PR.
Happy number-crunching!
Release files for numbr 2.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| numbr-2.0.6.tar.gz | 25.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| numbr-2.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 51.0 kB
Release files / numbr-2.0.6.tar.gz
| Download URL | numbr-2.0.6.tar.gz |
|---|---|
| Size | 25.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
def83dce038b0fe93eeca07b6d7b6aeb88b9dec7a38f7e3bbd5096ce52dfad84
|
|
BLAKE2b-256 checksum How to use checksums |
482908b5c01d4bd7bbcd5dfdaa03fee96a832efac0dfb68a4440eb01264236ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.8.5
|
Release files / numbr-2.0.6-py3-none-any.whl
| Download URL | numbr-2.0.6-py3-none-any.whl |
|---|---|
| Size | 25.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2cadc6c3febe260adba64ca449b62a7be23fe5f00cb0d5be1c81c8227be42f96
|
|
BLAKE2b-256 checksum How to use checksums |
89217ab1470ab5ea39a06f5ef4dfe055f15302b122e8326f2fd6f99e55b2f2e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.8.5
|