{"id":5790,"library":"number-parser","title":"number-parser","description":"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.","status":"active","version":"0.3.2","language":"en","source_language":"en","source_url":"https://github.com/scrapinghub/number-parser/","tags":["natural language processing","number parsing","localization","text processing"],"install":[{"cmd":"pip install number-parser","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"note":"An import bug was fixed in v0.3.2; direct import from `number_parser` is the correct and stable path.","wrong":"from number_parser.parser import parse","symbol":"parse","correct":"from number_parser import parse"},{"symbol":"parse_number","correct":"from number_parser import parse_number"},{"note":"Supports English only.","symbol":"parse_ordinal","correct":"from number_parser import parse_ordinal"},{"note":"Supports English only.","symbol":"parse_fraction","correct":"from number_parser import parse_fraction"}],"quickstart":{"code":"from number_parser import parse\n\n# Convert numbers in a sentence\ntext = \"I have two hats and thirty seven coats.\"\nparsed_text = parse(text)\nprint(f\"Original: {text}\\nParsed: {parsed_text}\")\n\n# Convert a single number in words\nnumber_in_words = \"two thousand and twenty\"\nparsed_number = parse_number(number_in_words)\nprint(f\"Number '{number_in_words}' parsed to: {parsed_number}\")","lang":"python","description":"Demonstrates how to use `parse` for in-place number conversion within a string and `parse_number` for converting a standalone number written in words."},"warnings":[{"fix":"Upgrade to number-parser >= 0.3.2. Ensure imports are directly from `number_parser` (e.g., `from number_parser import parse`) and not from internal modules like `number_parser.parser`.","message":"Prior to version 0.3.2, users might have encountered an import bug (#91), which could lead to incorrect or failed imports of the parsing functions. This was fixed in version 0.3.2.","severity":"breaking","affected_versions":"<0.3.2"},{"fix":"Upgrade to number-parser >= 0.3.1 to benefit from the fix for inconsistent whitespace handling.","message":"Inconsistent whitespace handling around sentence separators following numbers was an issue in versions prior to 0.3.1, potentially affecting parsing accuracy in specific contexts.","severity":"gotcha","affected_versions":"<0.3.1"},{"fix":"Consult the documentation for specific language support for each parsing function (e.g., `parse_ordinal` and `parse_fraction` are English-only). Ensure your input language matches the supported features.","message":"The library's language support is granular: cardinal numbers are supported in multiple languages, but ordinal numbers and simple fractions are currently supported only for English. Attempting to parse non-English ordinals or fractions might yield unexpected results or errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Test the library with a representative sample of your natural language number inputs. Be mindful of potential ambiguities and, if necessary, preprocess inputs or provide clearer phrasing.","message":"Parsing natural language numbers can be inherently ambiguous, especially across different locales and contexts (e.g., 'one hundred thousand' vs. 'one, hundred thousand'). While the library aims for robust parsing, complex or unusual phrasing might not always be interpreted as expected.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}