new PredicateArgumentView(this.predicateArgumentViewName, "GoldStandard", ta, 1.0); scoresDoubleArray[relationId] = 1.0; pav.addPredicateArguments(predicate, args, relations.toArray(new String[relations.size()]), scoresDoubleArray);
private Map<Constituent, Constituent> getGoldToPredictionPredicateMapping() { Map<Constituent, Constituent> goldToPredictionPredicateMapping = new HashMap<>(); for (Constituent gp : gold.getPredicates()) { for (Constituent pp : prediction.getPredicates()) { if (gp.getSpan().equals(pp.getSpan())) { goldToPredictionPredicateMapping.put(gp, pp); break; } } } return goldToPredictionPredicateMapping; } }
public void addPredicateArguments(Constituent predicate, List<Constituent> args, String[] relations, double[] scores) { if (args.size() != relations.length) { throw new IllegalArgumentException("Number of arguments != number of relations"); } if (args.size() != scores.length) { throw new IllegalArgumentException("Number of arguments != number of scores"); } this.addConstituent(predicate); this.predicates.add(predicate); for (int i = 0; i < args.size(); i++) { if(!this.containsConstituent(args.get(i))) this.addConstituent(args.get(i)); this.addRelation(new Relation(relations[i], predicate, args.get(i), scores[i])); } }
private static void convertPredicateArgView(TextAnnotation ta, PredicateArgumentView pav, List<String[]> columns, boolean addSense) { List<Constituent> predicates = new ArrayList<>(); if (pav != null) predicates = pav.getPredicates(); Collections.sort(predicates, TextAnnotationUtilities.constituentStartComparator); int size = ta.size(); addPredicateInfo(columns, predicates, size, addSense); for (Constituent predicate : predicates) { assert pav != null; List<Relation> args = pav.getArguments(predicate); String[] paInfo = addPredicateArgInfo(predicate, args, size); columns.add(paInfo); } }
new PredicateArgumentView(srlViewName, "AnnotatedTreebank", ta, 1.0); pav.addPredicateArguments(predicate, args, labels.toArray(new String[labels.size()]), ArrayUtilities.asDoubleArray(scores)); if (pav.getPredicates().size() > 0) ta.addView(srlViewName, pav);
@Override public List<XmlTextAnnotation> getAnnotationsFromFile(List<Path> corpusFileListEntry) throws Exception { XmlTextAnnotation xmlTa = super.getAnnotationsFromFile(corpusFileListEntry).get(0); TextAnnotation sourceTa = xmlTa.getTextAnnotation(); // SpanLabelView tokens = (SpanLabelView)sourceTa.getView(ViewNames.TOKENS); View mentionView = sourceTa.getView(getMentionViewName()); if (null == mentionView) throw new IllegalStateException("View '" + getMentionViewName() + "' (mention view) not found."); PredicateArgumentView eventView = new PredicateArgumentView(getEventViewName(), NAME, sourceTa, 1.0); // process one or more files containing stand-off annotations for (int i = 1; i < corpusFileListEntry.size(); ++i) { Document doc = SimpleXMLParser.getDocument(corpusFileListEntry.get(i).toFile()); getEventsFromFile(doc, eventView, xmlTa); } sourceTa.addView(getEventViewName(), eventView); return Collections.singletonList(xmlTa); }
new PredicateArgumentView(viewName, "illinois-comma", ta, 1.0d); for (Comma comma : sentence.getCommas()) { String label = classifier.discreteValue(comma); Constituent predicate = new Constituent("Predicate:" + label, viewName, ta, position, position + 1); predicate.addAttribute(PredicateArgumentView.SenseIdentifer, label); srlView.addConstituent(predicate); Constituent leftArg = comma.getPhraseToLeftOfComma(1); if (leftArg != null) { new Constituent(leftArg.getLabel(), viewName, ta, leftArg.getStartSpan(), leftArg.getEndSpan()); srlView.addConstituent(leftArgConst); srlView.addRelation(new Relation("LeftOf" + label, predicate, leftArgConst, 1.0d)); new Constituent(rightArg.getLabel(), viewName, ta, rightArg.getStartSpan(), rightArg.getEndSpan()); srlView.addConstituent(rightArgConst); srlView.addRelation(new Relation("RightOf" + label, predicate, rightArgConst, 1.0d));
private void populateAttribution(TextAnnotation ta, Map<String, AttributionRelation> attrRelations) { PredicateArgumentView attrRelationView = new PredicateArgumentView(VIEW_NAME, "Gold-PARC3", ta , 1.0D); Constituent cueC = new Constituent(LABEL_CUE, attrRelationView.getViewName(), ta, cue.getFirst(), cue.getSecond()); cueC.addAttribute(CON_ATTR_REL_ID, relationId); Constituent con = new Constituent(LABEL_CONTENT, attrRelationView.getViewName(), ta, c.getFirst(), c.getSecond()); con.addAttribute(CON_ATTR_REL_ID, relationId); return con; Constituent con = new Constituent(LABEL_SOURCE, attrRelationView.getViewName(), ta, c.getFirst(), c.getSecond()); con.addAttribute(CON_ATTR_REL_ID, relationId); attrRelationView.addPredicateArguments(cueC, merged, relations.stream().toArray(String[]::new), score); ta.addView(attrRelationView.getViewName(), attrRelationView);
new PredicateArgumentView(ViewNames.SRL_VERB, "GoldStandard", ta, 1.0); scoresDoubleArray[relationId] = 1.0; pav.addPredicateArguments(predicate, args, relations.toArray(new String[relations.size()]), scoresDoubleArray); if(pav.getConstituents().size() > 0) { ta.addView(ViewNames.SRL_VERB, pav);
new PredicateArgumentView(viewName, "PathLSTMGenerator", ta, 1.0); pav.addConstituent(predicate); finalTokenOffset + span.getFirst(), finalTokenOffset + span.getSecond()); assert span.getFirst() <= span.getSecond() : ta; List<Constituent> consList = pav.getConstituentsWithSpan( new IntPair(finalTokenOffset + span.getFirst(), finalTokenOffset + span.getSecond())); if (consList.isEmpty()) { pav.addConstituent(c); pav.addRelation(new Relation(argLabel, predicate, c, 1.0));
PredicateArgumentView pav; pav = (PredicateArgumentView) srlTA.getView(ViewNames.SRL_VERB); for (Constituent pred : pav.getPredicates()) { for (Relation rel : pav.getArguments(pred)) { if (rel.getTarget().getEndSpan() > commaPosition && rel.getTarget().getStartSpan() >= commaPosition) list.add(pav.getPredicateLemma(rel.getSource()) + rel.getRelationName()); for (Constituent pred : pav.getPredicates()) { for (Relation rel : pav.getArguments(pred)) { if (rel.getTarget().getEndSpan() > commaPosition && rel.getTarget().getStartSpan() >= commaPosition) list.add(pav.getPredicateLemma(rel.getSource()) + rel.getRelationName()); for (Constituent pred : pav.getPredicates()) { for (Relation rel : pav.getArguments(pred)) { if (rel.getTarget().getEndSpan() > commaPosition && rel.getTarget().getStartSpan() >= commaPosition) list.add(pav.getPredicateLemma(rel.getSource()) + rel.getRelationName());
for (Relation r : view.getArguments(predicate)) { Constituent target = r.getTarget(); output.add(new Pair<>(r.getRelationName(), target)); logger.error("Error! Overlapping spans in " + view.getViewName() + "\n" + view.getTextAnnotation() + "\n" + view);
newVu = new CoreferenceView(vu.viewName, vu.viewGenerator, newTA, vu.score); } else if (vu instanceof PredicateArgumentView) { newVu = new PredicateArgumentView(vu.viewName, vu.viewGenerator, newTA, vu.score); } else if (vu instanceof TreeView) { newVu = new TreeView(vu.viewName, vu.viewGenerator, newTA, vu.score); ((PredicateArgumentView) vu).findPredicates();
StringBuilder sb = new StringBuilder(); List<Constituent> p = new ArrayList<>(this.getPredicates()); String pred = getPredicateLemma(predicate) + ":" + getPredicateSense(predicate);
Constituent predicate = new Constituent(label, srlView.getViewName(), ta, constituent.getStartSpan(), constituent.getEndSpan()); predicate.addAttribute(PredicateArgumentView.LemmaIdentifier, constituent.getSurfaceForm()); predicate.addAttribute(PredicateArgumentView.SenseIdentifer, node.getSense()); PredicateArgument a = arguments.get(i); String rclabel = arg; Constituent rc = new Constituent(rclabel, srlView.getViewName(), ta, a.pair.getFirst(), a.pair.getSecond()); double[] scores = new double[tempArgLabels.size()]; for (int i = 0; i < scores.length; i++) scores[i] = 1.0; srlView.addPredicateArguments(predicate, args, argLabels, scores, continuationArgs);
trigger.addAttribute(WAYS, ways); eventView.addConstituent(trigger); numEventMentionsGenerated++; isEventGenerated = true; role.addAttribute(REALIS, roleRealisOrigin.get(1)); role.addAttribute(ORIGIN, roleRealisOrigin.get(2)); eventView.addConstituent(ac); eventView.addRelation(role);
private static void addSrlFrame(PredicateArgumentView srlView, String viewName, TextAnnotation ta, IntPair verbSRLPredicate, String sense, Map<IntPair, String> srlArgs) { Constituent predicate = new Constituent("predicate", viewName, ta, verbSRLPredicate.getFirst(), verbSRLPredicate.getSecond()); predicate.addAttribute(PredicateArgumentView.LemmaIdentifier, lemmasAll[verbSRLPredicate.getFirst()]); predicate.addAttribute(PredicateArgumentView.SenseIdentifer, sense); List<Constituent> args = new ArrayList<>(); List<String> tempArgLabels = new ArrayList<>(); for (IntPair span : srlArgs.keySet()) { args.add(new Constituent("argument", viewName, ta, span.getFirst(), span.getSecond())); tempArgLabels.add(srlArgs.get(span)); } String[] argLabels = tempArgLabels.toArray(new String[args.size()]); double[] scores = new double[args.size()]; srlView.addPredicateArguments(predicate, args, argLabels, scores); } }
public void printPredicateArgumentView(PredicateArgumentView pav, PrintWriter out) { // System.out.println("*" + pav + "*"); List<String[]> columns = new ArrayList<>(); convertPredicateArgView(pav.getTextAnnotation(), pav, columns, false); String[][] tr = transpose(columns, pav.getTextAnnotation().size()); printFormatted(tr, out, pav.getTextAnnotation()); }
new PredicateArgumentView(srlViewName, "AnnotatedTreebank", ta, 1.0); pav.addPredicateArguments(predicate, args, labels.toArray(new String[labels.size()]), ArrayUtilities.asDoubleArray(scores)); if (pav.getPredicates().size() > 0) ta.addView(srlViewName, pav);
@Override public List<XmlTextAnnotation> getAnnotationsFromFile(List<Path> corpusFileListEntry) throws Exception { XmlTextAnnotation xmlTa = super.getAnnotationsFromFile(corpusFileListEntry).get(0); TextAnnotation sourceTa = xmlTa.getTextAnnotation(); // SpanLabelView tokens = (SpanLabelView)sourceTa.getView(ViewNames.TOKENS); View mentionView = sourceTa.getView(getMentionViewName()); if (null == mentionView) throw new IllegalStateException("View '" + getMentionViewName() + "' (mention view) not found."); PredicateArgumentView eventView = new PredicateArgumentView(getEventViewName(), NAME, sourceTa, 1.0); // process one or more files containing stand-off annotations for (int i = 1; i < corpusFileListEntry.size(); ++i) { Document doc = SimpleXMLParser.getDocument(corpusFileListEntry.get(i).toFile()); getEventsFromFile(doc, eventView, xmlTa); } sourceTa.addView(getEventViewName(), eventView); return Collections.singletonList(xmlTa); }