Example usage for edu.stanford.nlp.trees LabeledScoredTreeFactory newTreeNode

List of usage examples for edu.stanford.nlp.trees LabeledScoredTreeFactory newTreeNode

Introduction

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

Prototype

@Override
public Tree newTreeNode(Label parentLabel, List<Tree> children) 

Source Link

Document

Create a new non-leaf tree node with the given label

Usage

From source file:qmul.util.treekernel.Production.java

License:Open Source License

public Production(String bnf) {
    String[] fields = bnf.trim().split(Pattern.quote(SEPARATOR));
    if (fields.length < 2) {
        throw new RuntimeException("too few BNF fields " + bnf);
    }//w  ww .j  a va2s  .c o m
    LabeledScoredTreeFactory tf = new LabeledScoredTreeFactory();
    ArrayList<Tree> children = new ArrayList<Tree>();
    for (int i = 1; i < fields.length; i++) {
        children.add(tf.newLeaf(fields[i]));
    }
    node = tf.newTreeNode(fields[0], children);
    setBnf();
    if (!this.bnf.equals(bnf)) {
        throw new RuntimeException("BNFs not equal: " + bnf + " vs " + this.bnf);
    }
}