CodeNoob
CodeNoob

Reputation: 1840

text-mining: Determine to which noun a verb refers?

I'm trying to find a package/library which enables me to determine to which noun a verb refers (in Python):

The man was walking down the street

That this will give me a result like walking refers to man.
I tried to use nltk however as far as I could find out I can only tag the wordst as nouns/verbs etc. but cannot infer any references from this.

Question
Are there any packages which are capable to do the above?

Upvotes: 2

Views: 788

Answers (1)

David Batista
David Batista

Reputation: 3134

I think what you want to do is explore the syntactic dependencies among words. For that, you need to parse your text with a syntactic parser.

Since you want to know the references between nouns and verbs you will need to do two things.

You need to get the part-of-speech tags associated to each words (i.e. the morphology associated to each word, wether it's a ADJ, DET, VERB, NOUN, etc.) then you want to select the ones tagged as verbs and nouns.

Then, you want to look at which other words they connect with, I think mostly you will want to explore the 'nsubj' dependency.

spaCy is a NLP library for Python that performs syntactic parsing, and also has a on-line demo, if you want to try it out, check:

https://demos.explosion.ai/displacy/

Here is the output for the example you gave:

enter image description here

Upvotes: 3

Related Questions