--- id: text2digits version: "0.1.2" license: MIT license_treatment: permissive maintenance: active --- # text2digits — A small library to convert text numbers to digits in a string License: permissive · Maintenance: active · Downloads: 242.4K/mo ## What it is and what it does text2digits is a lightweight Python library that recognizes number words written as text—like "twenty ten", "one thousand six hundred sixty six", or "negative thirty seven"—and replaces them with their numeric equivalents in a string. It handles both cardinal numbers (one, two, three) and ordinals (first, second, third), supports informal year-style concatenation ("twenty ten" becomes "2010"), and works with multiple number systems including the Indian scales (lakh, crore, arab, kharab). The library is designed for post-processing speech-to-text output, particularly from voice assistants like Alexa or Lex, where spoken numbers arrive as words and need to be normalized to digits. The package has no runtime dependencies and installs as a pure Python wheel. It recognizes a wide variety of phrasings—both formal and conversational—and can correct minor spelling variations. Known limitations include that negative numbers preserve the word "negative" rather than converting to a minus sign, and ordinal suffixes are dropped by default ("third" becomes "3" not "3rd") unless explicitly enabled. Decimal literals adjacent to scale words are supported ("2.5 thousand" becomes "2500"). Use it for: - Clean up Alexa or Lex transcription output where spoken numbers appear as words rather than digits. - Normalize user input from voice interfaces before storing or processing numeric data. - Parse informal written descriptions containing number words (e.g., chat logs, survey responses) into machine-readable form. - Convert year expressions in narrative text ("born in nineteen ninety two") to standard numeric format. - Handle ordinal references in text ("the fourth cousin") by converting them to digit form for indexing or comparison. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Converts written-out number words in text to their digit equivalents, handling both formal and informal phrasing across a range of scales and styles. Yes. The package is lightweight, actively maintained, has no dependencies, and solves a specific problem well—converting spoken/written number words to digits. It's particularly valuable if you work with speech-to-text pipelines. The MIT license imposes no restrictions. No known vulnerabilities. Install it if you need this conversion; skip it if your input is already numeric. ## Install pip install text2digits uv add text2digits poetry add text2digits ## Installing text2digits Before you install: Low friction: pure Python wheel with no runtime dependencies. Actively maintained as of 2026-04-28 with a recent commit history. License in practice: MIT license permits unrestricted use, modification, and distribution in both open and closed projects with minimal attribution requirements. Quickstart: pip install text2digits from text2digits import text2digits t2d = text2digits.Text2Digits() result = t2d.convert("I am twenty nine years old") print(result) # 'I am 29 years old' Requires Python 3.7 or later. Verify before relying: - Whether the package handles all edge cases in production speech-to-text pipelines beyond the documented examples. - Performance characteristics when processing very long strings or batch operations. - Whether the similarity_threshold spelling correction feature is suitable for your use case's accuracy requirements. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 242.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags convert text numbers to digits, number words to numerals, text to number conversion, written numbers parser, speech-to-text number cleanup, ordinal and cardinal conversion, natural language number parsing, nlp, speech-to-text, text-normalization [View on SkillFed](https://skillfed.io/packages/text2digits) · [View on PyPI](https://pypi.org/project/text2digits/)