use of edu.stanford.nlp.ling.WordFactory in project CoreNLP by stanfordnlp.
the class TreebankAnnotator method getTrees.
public static List<Tree> getTrees(String path, int low, int high, int minLength, int maxLength) {
Treebank treebank = new DiskTreebank(in -> new PennTreeReader(in, new LabeledScoredTreeFactory(new WordFactory()), new BobChrisTreeNormalizer()));
treebank.loadPath(path, new NumberRangeFileFilter(low, high, true));
List<Tree> trees = new ArrayList<>();
for (Tree tree : treebank) {
if (tree.yield().size() <= maxLength && tree.yield().size() >= minLength) {
trees.add(tree);
}
}
return trees;
}
Aggregations