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.
pip install number-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use `parse` for in-place number conversion within a string and `parse_number` for converting a standalone number written in words.
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`.
Upgrade to number-parser >= 0.3.1 to benefit from the fix for inconsistent whitespace handling.
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.
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.
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`).
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.')`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()`.
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.No dependency data recorded yet.