问题
I want to extract the subject, predicate, and object of a sentence and find out which adjectives go to the subject, predicate, or object with Stanford CoreNLP in java code.
I have tried to use the dependency parser to solve this by finding the dependency index, checking the dependency tag if it equals amod, then adding it to an ArrayList, but with this method sometimes the adjective's dependency tag is not amod and is nmod, and other tags may come up.
With determining the object and predicate, I have used a similar method as above. I have checked if it is det, and if it is any other tags that mean it is a predicate or object. However, sometimes different tags come up and it is not efficient to have to parse every tag that somewhat means it is a predicate pointing to the object.
So my question is, how to I get the subject, predicate, and object of a sentence and each's adjectives but not need to check each tag?
For the above mentioned attempts, I have used Stanford CoreNLP Simple API, but I am OK with the standard API if it is truly needed.
回答1:
You should try out the openie
annotator which will find (subject, predicate, object) triples.
example command:
java -Xmx5g edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,ner,depparse,coref,natlog,openie -file basic-example.txt -outputFormat text
example:
The tall man ate the delicious pizza.
example output:
1.0 man ate pizza
1.0 man ate delicious pizza
1.0 tall man ate pizza
1.0 tall man ate delicious pizza
来源:https://stackoverflow.com/questions/53435202/how-to-pick-out-a-the-subject-predicate-and-object-and-adjectives-in-a-sentenc