2
$\begingroup$

I am asking for tools (possibly in NLTK) or papers that talk about the following:

e.g. Input: Vase(Subject1) put(verb)

Ans I am looking for: flower, water

Is there a tool that can output subjects (objects) that can be associated to this verb? (I was going through VerbNet but didn't find anything)

$\endgroup$
  • 2
    $\begingroup$ It is not natural English to say "Vase put ...". A speaker might say "I put water in the vase" or as a request (to un-mentioned listener) "Put water in the vase". In both cases the vase here would be a referred object and not the subject (compared to "The vase is green" or "The glass vase broke" where the vase is the subject). I don't think that changes the question substantially, but you may want to work on a clearer example $\endgroup$ – Neil Slater Apr 2 '19 at 17:21
  • $\begingroup$ If you want Subject, Verb, Object for your vase example, you might simply change it to "Vase (subject) contains (verb)" or "Vase (subject) holds (verb)" - but if you really want to parse a request for putting something in a vase, then that would be different $\endgroup$ – Neil Slater Apr 2 '19 at 17:34
0
$\begingroup$

If you want something quick, I think pattern is the best tool for the job. It provides a ready-to-use multilingual parser that you can use in the following way:

import pattern
from pattern.en import parse
s = 'I put water in the vase'
s = parse(s)
print s
# output = I/PRP/B-NP/O put/VBP/B-VP/O water/NN/B-NP/O in/IN/B-PP/B-PNP the/DT/B-NP/I-PNP vase/NN/I-NP/I-PNP

Once you have a string like output above, you only need regex parsing to extract every sequence of tokens whose tags match the sequence [B-NP, B-VP, B-NP].

NP stands for "noun phrase" and VP stands for "verb phrase". In English, virtually every sequence consisting of a noun phrase, a verb phrase, and a second noun phrase, all in strict adjacency, is a subject-verb-object sequence, so this should give you what you're looking for.

pattern's parser will also be able to handle some non-strict adjacencies (e.g. intervening adverbs and adjectives between the three phrases in the subject-verb-object sequence).

However, pattern is not terribly sophisticated -this will give you some Precision and some Recall, but not terribly high numbers. If you need high-quality parsing, you should try the Stanford parser's Python implementation or spacy.

Hope this helps!

| improve this answer | |
$\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.