2
$\begingroup$

Given text data, I'd like to extract numerical information based on the presence of other information.

For instance, "There are 119 people in the gym right now. 100 people in the weight room, 19 on treadmills". If I was interested in "weight room" then I would extract "100" or if I was interested in "treadmills" then I would extract "19".

I can create dependency trees with Python's spaCy package. Is there a way to extract these dependencies?

$\endgroup$
1
  • $\begingroup$ You can use regular expressions to look for numbers. $\endgroup$ – user50579 Dec 19 '17 at 21:26
1
$\begingroup$

If your data is always as clean as this, you might be able to solve the problem using simple regular expressions. You could simply look for the first number that occurs before the string of interest.

As to the dependency parsing using spacy, this is the output that your sentence would get

There expl are VERB [] are ROOT are VERB [There, people, now, .] 119 nummod people NOUN [] people attr are VERB [119, in] in prep people NOUN [gym] the det gym NOUN [] gym pobj in ADP [the] right advmod now ADV [] now advmod are VERB [right] . punct are VERB [] 100 nummod people NOUN [] people ROOT people NOUN [100, in, ,, 19] in prep people NOUN [room] the det room NOUN [] weight compound room NOUN [] room pobj in ADP [the, weight] , punct people NOUN [] 19 appos people NOUN [on] on prep 19 NUM [treadmills] treadmills pobj on ADP []

Meaning that you would need to first locate weight room, and then trace back to 100, which in this case might simply be more complicated than using regular expressions.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.