Search in sources :

Example 1 with BasicTextAnnotationBuilder

use of edu.illinois.cs.cogcomp.annotation.BasicTextAnnotationBuilder in project cogcomp-nlp by CogComp.

the class CoNLLColumnFormatReader method main.

public static void main(String[] args) throws Exception {
    String columnFile = "02.feats";
    CoNLLColumnFormatReader reader = new CoNLLColumnFormatReader("PennTreebank-WSJ", "02", columnFile, ViewNames.SRL_VERB, new BasicTextAnnotationBuilder());
    Counter<String> counter = new Counter<>();
    List<String> predicates = new ArrayList<>();
    for (TextAnnotation ta : reader) {
        counter.incrementCount("Sentences");
        System.out.println(ta.getTokenizedText());
        if (!ta.hasView(ViewNames.SRL_VERB))
            continue;
        PredicateArgumentView pav = (PredicateArgumentView) ta.getView(ViewNames.SRL_VERB);
        List<Constituent> predicates2 = pav.getPredicates();
        counter.incrementCount("Predicates", predicates2.size());
        for (Constituent c : predicates2) {
            predicates.add(c.getAttribute(PredicateArgumentView.LemmaIdentifier));
        }
    }
    System.out.println((int) counter.getCount("Sentences") + " sentences");
    System.out.println((int) counter.getCount("Predicates") + " predicates");
}
Also used : BasicTextAnnotationBuilder(edu.illinois.cs.cogcomp.annotation.BasicTextAnnotationBuilder) Counter(edu.illinois.cs.cogcomp.core.stats.Counter) ArrayList(java.util.ArrayList)

Aggregations

BasicTextAnnotationBuilder (edu.illinois.cs.cogcomp.annotation.BasicTextAnnotationBuilder)1 Counter (edu.illinois.cs.cogcomp.core.stats.Counter)1 ArrayList (java.util.ArrayList)1