Example usage for edu.stanford.nlp.trees SemanticHeadFinder SemanticHeadFinder

List of usage examples for edu.stanford.nlp.trees SemanticHeadFinder SemanticHeadFinder

Introduction

In this page you can find the example usage for edu.stanford.nlp.trees SemanticHeadFinder SemanticHeadFinder.

Prototype

public SemanticHeadFinder(boolean noCopulaHead) 

Source Link

Usage

From source file:ipgraph.datastructure.DTree.java

License:Open Source License

/** **************************************************************
 * Build dependency-tree from a plain sentence
 *//*  w w w. jav  a  2 s .  c  o m*/
public static DTree buildTree(String s) {
    StanfordPCFGParser pcfgParser = new StanfordPCFGParser("", false);
    Tree tree = pcfgParser.getLexicalizedParser().parse(s);

    SemanticHeadFinder headFinder = new SemanticHeadFinder(false); // keep copula verbs as head
    GrammaticalStructure egs = new EnglishGrammaticalStructure(tree, string -> true, headFinder, true);

    // notes: typedDependencies() is suggested
    String conllx = EnglishGrammaticalStructure.dependenciesToString(egs, egs.typedDependencies(), tree, true,
            true);

    DTree dtree = LangTools.getDTreeFromCoNLLXString(conllx, true);
    return dtree;
}