Search code examples
javastanford-nlp

Stanford CoreNLP - Phrase level POS


I'm trying to use the CoreNLP and would like to know if its possible to split the sentence using just the phrase level without going into detail with to the word level.

Basically, I want to analyze a sentence then obtain the phrase tags of it, then obtain the splits into variables.

For example, for a sentence, if it contains the noun phrase(X) and verb phrase (Y), I want to analyze using CoreNLP the X and Y, then obtain X and Y separately into variables.

Any idea on how to do it?


Solution

  • There is some sample code in my answer to this question which demonstrates how to access the constituency parse

    I provided a sample class called RootFinderExample.java.

    How to get the root node in Stanford Parse-Tree?

    Here is where the Tree is accessed:

    Tree tree = sentence.get(TreeAnnotation.class);
    

    Here is some documentation on the Tree class:

    http://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/trees/Tree.html