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

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

Introduction

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

Prototype

@Override
public Tree newLeaf(Label label) 

Source Link

Document

Create a new leaf 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);
    }//from www .  j  a  va 2  s.  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);
    }
}