number-parser

0.3.2 · active · verified Tue Apr 14

number-parser is a Python library designed to convert numbers written in natural language into their equivalent numeric forms. It supports cardinal numbers in English, Hindi, Spanish, Ukrainian, and Russian, and also handles ordinal numbers and simple fractions in English. The current version is 0.3.2, and it maintains an active, though somewhat irregular, release cadence with several updates in early 2023.

Warnings

Install

Imports

Quickstart

Demonstrates how to use `parse` for in-place number conversion within a string and `parse_number` for converting a standalone number written in words.

from number_parser import parse

# Convert numbers in a sentence
text = "I have two hats and thirty seven coats."
parsed_text = parse(text)
print(f"Original: {text}\nParsed: {parsed_text}")

# Convert a single number in words
number_in_words = "two thousand and twenty"
parsed_number = parse_number(number_in_words)
print(f"Number '{number_in_words}' parsed to: {parsed_number}")

view raw JSON →