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"); }
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"); }