Search in sources :

Example 1 with ChineseGrammaticalStructure

use of edu.stanford.nlp.trees.international.pennchinese.ChineseGrammaticalStructure in project CoreNLP by stanfordnlp.

the class CoNLLDocumentReader method setDependencyTree.

private void setDependencyTree(Annotation anno) {
    List<CoreMap> sentences = anno.get(SentencesAnnotation.class);
    for (CoreMap sentence : sentences) {
        Tree tree = sentence.get(TreeAnnotation.class);
        if (tree == null)
            continue;
        SemanticGraph deps = null;
        SemanticGraph basicDeps = null;
        if (options.lang == Locale.CHINESE) {
            final boolean threadSafe = true;
            deps = SemanticGraphFactory.makeFromTree(new ChineseGrammaticalStructure(tree, Filters.acceptFilter(), chineseHeadFinder), SemanticGraphFactory.Mode.COLLAPSED, GrammaticalStructure.Extras.NONE, null);
            basicDeps = SemanticGraphFactory.makeFromTree(new ChineseGrammaticalStructure(tree, Filters.acceptFilter(), chineseHeadFinder), SemanticGraphFactory.Mode.BASIC, GrammaticalStructure.Extras.NONE, null);
        } else {
            deps = SemanticGraphFactory.generateEnhancedDependencies(tree);
            basicDeps = SemanticGraphFactory.generateUncollapsedDependencies(tree);
        }
        sentence.set(SemanticGraphCoreAnnotations.BasicDependenciesAnnotation.class, basicDeps);
        sentence.set(SemanticGraphCoreAnnotations.EnhancedDependenciesAnnotation.class, deps);
    }
}
Also used : ChineseGrammaticalStructure(edu.stanford.nlp.trees.international.pennchinese.ChineseGrammaticalStructure) SemanticGraphCoreAnnotations(edu.stanford.nlp.semgraph.SemanticGraphCoreAnnotations) Tree(edu.stanford.nlp.trees.Tree) SemanticGraph(edu.stanford.nlp.semgraph.SemanticGraph) CoreMap(edu.stanford.nlp.util.CoreMap)

Aggregations

SemanticGraph (edu.stanford.nlp.semgraph.SemanticGraph)1 SemanticGraphCoreAnnotations (edu.stanford.nlp.semgraph.SemanticGraphCoreAnnotations)1 Tree (edu.stanford.nlp.trees.Tree)1 ChineseGrammaticalStructure (edu.stanford.nlp.trees.international.pennchinese.ChineseGrammaticalStructure)1 CoreMap (edu.stanford.nlp.util.CoreMap)1