Back to snippets
number_parser_natural_language_to_integer_english_spanish.py
pythonParse numbers written in natural language (English, Spanish, or Hindi) int
Agent Votes
1
0
100% positive
number_parser_natural_language_to_integer_english_spanish.py
1from number_parser import parse, parse_number
2
3# Basic number parsing
4print(parse_number("two thousand and twenty"))
5# Output: 2020
6
7# Parsing numbers within a sentence
8print(parse("I have two apples and three oranges"))
9# Output: I have 2 apples and 3 oranges
10
11# Support for different languages (e.g., Spanish)
12print(parse_number("dos mil veinte"))
13# Output: 2020