Search in sources :

Example 1 with WordFactory

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;
}
Also used : NumberRangeFileFilter(edu.stanford.nlp.io.NumberRangeFileFilter) WordFactory(edu.stanford.nlp.ling.WordFactory)

Aggregations

NumberRangeFileFilter (edu.stanford.nlp.io.NumberRangeFileFilter)1 WordFactory (edu.stanford.nlp.ling.WordFactory)1