Search in sources :

Example 1 with LabeledConstituent

use of edu.stanford.nlp.trees.LabeledConstituent in project CoreNLP by stanfordnlp.

the class TreeSpanScoring method simplifyConstituents.

public static Set<Constituent> simplifyConstituents(TreebankLanguagePack tlp, Set<Constituent> constituents) {
    Set<Constituent> newConstituents = new HashSet<>();
    for (Constituent con : constituents) {
        if (!(con instanceof LabeledConstituent)) {
            throw new AssertionError("Unexpected constituent type " + con.getClass());
        }
        LabeledConstituent labeled = (LabeledConstituent) con;
        newConstituents.add(new LabeledConstituent(labeled.start(), labeled.end(), tlp.basicCategory(labeled.value())));
    }
    return newConstituents;
}
Also used : LabeledConstituent(edu.stanford.nlp.trees.LabeledConstituent) Constituent(edu.stanford.nlp.trees.Constituent) LabeledConstituent(edu.stanford.nlp.trees.LabeledConstituent) HashSet(java.util.HashSet)

Aggregations

Constituent (edu.stanford.nlp.trees.Constituent)1 LabeledConstituent (edu.stanford.nlp.trees.LabeledConstituent)1 HashSet (java.util.HashSet)1