List of usage examples for edu.stanford.nlp.trees LabeledScoredTreeFactory newLeaf
@Override
public Tree newLeaf(Label label)
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); } }