How to extract numbers (along with comparison adjectives or ranges)

Viewed 5677

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:

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}
1 Answers
Related