{"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":"python","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,"search_vec":"'0.3.2':49 '2023':65 'activ':54 'also':36 'cadenc':59 'cardin':26 'convert':13 'current':46 'design':11 'earli':64 'english':29,44 'equival':21 'form':23 'fraction':42 'handl':37 'hindi':30 'irregular':57 'languag':18,67 'librari':10 'local':71 'maintain':52 'natur':17,66 'number':2,5,14,27,39,69 'number-pars':1,4 'numer':22 'ordin':38 'pars':70 'parser':3,6 'process':68,73 'python':9 'releas':58 'russian':34 'sever':61 'simpl':41 'somewhat':56 'spanish':31 'support':25 'text':72 'though':55 'ukrainian':32 'updat':62 'version':47 'written':15","created_at":"2026-04-14T05:07:14.056136+00:00","updated_at":"2026-04-16T17:25:15.448958+00:00","problems":[{"fix":"Ensure the library is installed using pip: `pip install number-parser`. Then, import correctly as `from number_parser import parse` (note the underscore in `number_parser`).","cause":"The `number-parser` library is not installed in the current Python environment or there's a typo in the import statement.","error":"ModuleNotFoundError: No module named 'number_parser'"},{"fix":"Check the return value of `parse_number` for `None` to handle unparseable input gracefully. For parsing numbers embedded in text, use the `parse` function instead. Example: `result = parse_number('not_a_number')` then `if result is None: print('Input could not be parsed.')`","cause":"The `parse_number` function is designed to convert a single number written in words (e.g., 'two thousand') to its integer form. Providing a string that does not represent a valid number in this format will result in `None` being returned, which users might perceive as an error if they expect an exception or a default numeric value.","error":"parse_number('not_a_number')"},{"fix":"Refer to the official documentation or examples for the correct function names. For general string parsing, use `number_parser.parse()`. For single number parsing, use `number_parser.parse_number()`.","cause":"Users might guess function names based on common parsing patterns or misremember the API. The `number-parser` library uses `parse`, `parse_number`, `parse_ordinal`, and `parse_fraction` for its core functionalities, not `parse_string`.","error":"AttributeError: module 'number_parser' has no attribute 'parse_string'"},{"fix":"Ensure that the `language` parameter is set to one of the currently supported locales ('en', 'hi', 'es', 'uk', 'ru'). If a language is not supported, the library may not be suitable for that specific use case.","cause":"While `number-parser` supports several languages (English, Hindi, Spanish, Ukrainian, and Russian), attempting to use an unsupported language code with functions that accept a `language` parameter (e.g., `parse_number('one', language='french')`) will lead to incorrect parsing or unexpected behavior as the library will default to English or fail to recognize numbers in the unsupported language.","error":"number-parser 'language not supported'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.3.2","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/scrapinghub/number-parser","docs":null,"changelog":null,"pypi":"https://pypi.org/project/number-parser/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-31","next_check":"2026-07-28","install_tag":null}}