I am working on two NLP projects in Python, and both have a similar task to extract numerical values and comparison operators from sentences, like the following:
"... greater than $10 ... ",
"... weight not more than 200lbs ...",
"... height in 5-7 feets ...",
"... faster than 30 seconds ... "
I found two different approaches to solve this problem:
- using very complex regular expressions.
- using Named Entity Recognition (and some regexes, too).
How can I parse numerical values out of such sentences? I assume this is a common task in NLP.
The desired output would be something like:
Input:
"greater than $10"
Output:
{'value': 10, 'unit': 'dollar', 'relation': 'gt', 'position': 3}