for (Constituent gp : gold.getConstituents()) { for (Constituent pp : prediction.getConstituents()) { if (gp.getSpan().equals(pp.getSpan())) { goldToPredictionPredicateMapping.put(gp, pp); for (Constituent gp : gold.getConstituents()) { if (goldToPredictionPredicateMapping.containsKey(gp)) { Constituent pp = goldToPredictionPredicateMapping.get(gp);
for (Constituent gp : gold.getConstituents()) { for (Constituent pp : prediction.getConstituents()) { if (gp.getSpan().equals(pp.getSpan())) { goldToPredictionPredicateMapping.put(gp, pp); for (Constituent gp : gold.getConstituents()) { if (goldToPredictionPredicateMapping.containsKey(gp)) { Constituent pp = goldToPredictionPredicateMapping.get(gp);
private void getTreebankExamples(TextAnnotation ta, List<SenseInstance> predicates, List<SenseStructure> structures) { TokenLabelView view = (TokenLabelView) ta.getView(SenseManager.getGoldViewName()); for (Constituent predicate : view.getConstituents()) { if (!predicate.hasAttribute(PredicateArgumentView.LemmaIdentifier)) { System.out.println(ta); System.out.println(view); System.out.println(predicate + " has no lemma!"); assert false; } SenseInstance x = new SenseInstance(predicate, manager); int sense = manager.getSenseId(predicate.getLabel()); SenseStructure y = new SenseStructure(x, sense, manager); predicates.add(x); structures.add(y); } } }
private void getTreebankExamples(TextAnnotation ta, List<SenseInstance> predicates, List<SenseStructure> structures) { TokenLabelView view = (TokenLabelView) ta.getView(SenseManager.getGoldViewName()); for (Constituent predicate : view.getConstituents()) { if (!predicate.hasAttribute(PredicateArgumentView.LemmaIdentifier)) { System.out.println(ta); System.out.println(view); System.out.println(predicate + " has no lemma!"); assert false; } SenseInstance x = new SenseInstance(predicate, manager); int sense = manager.getSenseId(predicate.getLabel()); SenseStructure y = new SenseStructure(x, sense, manager); predicates.add(x); structures.add(y); } } }
private void addAnnotation(TextAnnotation ta) { String goldViewName = SenseManager.getGoldViewName(); Tree<String> tree = ParseHelper.getParseTree(ViewNames.PARSE_GOLD, ta, 0); Tree<Pair<String, IntPair>> spanLabeledTree = ParseUtils.getSpanLabeledTree(tree); List<Tree<Pair<String, IntPair>>> yield = spanLabeledTree.getYield(); TokenLabelView view = new TokenLabelView(goldViewName, "AnnotatedTreebank", ta, 1.0); Set<Integer> predicates = new HashSet<>(); for (PropbankFields fields : goldFields.get(ta.getId())) { int start = fields.getPredicateStart(yield); if (predicates.contains(start)) continue; predicates.add(start); view.addTokenLabel(start, fields.getSense(), 1.0); try { view.addTokenAttribute(start, LemmaIdentifier, fields.getLemma()); } catch (Exception e) { // XXX Maybe log the exception? e.printStackTrace(); } } if (view.getConstituents().size() > 0) ta.addView(goldViewName, view); } }
private void addAnnotation(TextAnnotation ta) { String goldViewName = SenseManager.getGoldViewName(); Tree<String> tree = ParseHelper.getParseTree(ViewNames.PARSE_GOLD, ta, 0); Tree<Pair<String, IntPair>> spanLabeledTree = ParseUtils.getSpanLabeledTree(tree); List<Tree<Pair<String, IntPair>>> yield = spanLabeledTree.getYield(); TokenLabelView view = new TokenLabelView(goldViewName, "AnnotatedTreebank", ta, 1.0); Set<Integer> predicates = new HashSet<>(); for (PropbankFields fields : goldFields.get(ta.getId())) { int start = fields.getPredicateStart(yield); if (predicates.contains(start)) continue; predicates.add(start); view.addTokenLabel(start, fields.getSense(), 1.0); try { view.addTokenAttribute(start, LemmaIdentifier, fields.getLemma()); } catch (Exception e) { // XXX Maybe log the exception? e.printStackTrace(); } } if (view.getConstituents().size() > 0) ta.addView(goldViewName, view); } }
ILPInference inference = manager.getInference(solver, gold.getConstituents());
ILPInference inference = manager.getInference(solver, gold.getConstituents());
List<Constituent> poss = posView.getConstituents();
List<Constituent> poss = posView.getConstituents();