public IntPair getSpan() { return c.getSpan(); }
/** * @return all the constituents that have exact span start/end. */ public List<Constituent> getConstituentsWithSpan(IntPair span) { List<Constituent> list = new ArrayList<>(); for(Constituent c : this.constituents) if (c.getSpan().equals(span)) list.add(c); return list; }
/** * @return all the constituents that have exact span start/end. */ public List<Constituent> getConstituentsWithSpan(IntPair span) { List<Constituent> list = new ArrayList<>(); for(Constituent c : this.constituents) if (c.getSpan().equals(span)) list.add(c); return list; }
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; } }
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 evaluate(ClassificationTester tester, View gold, View prediction) { super.cleanAttributes(gold, prediction); Set<IntPair> goldSpans = new HashSet<>(); for (Constituent cons : gold.getConstituents()) { goldSpans.add(cons.getSpan()); } Set<IntPair> predictedSpans = new HashSet<>(); for (Constituent cons : prediction.getConstituents()) { predictedSpans.add(cons.getSpan()); } Set<IntPair> spanIntersection = new HashSet<>(goldSpans); spanIntersection.retainAll(predictedSpans); tester.recordCount("" /* label doesn't matter */, goldSpans.size(), predictedSpans.size(), spanIntersection.size()); } }
public void evaluate(ClassificationTester tester, View gold, View prediction) { super.cleanAttributes(gold, prediction); Set<IntPair> goldSpans = new HashSet<>(); for (Constituent cons : gold.getConstituents()) { goldSpans.add(cons.getSpan()); } Set<IntPair> predictedSpans = new HashSet<>(); for (Constituent cons : prediction.getConstituents()) { predictedSpans.add(cons.getSpan()); } Set<IntPair> spanIntersection = new HashSet<>(goldSpans); spanIntersection.retainAll(predictedSpans); tester.recordCount("" /* label doesn't matter */, goldSpans.size(), predictedSpans.size(), spanIntersection.size()); } }
public int compare(Integer o1, Integer o2) { IntPair span1 = candidates.get(o1).getConstituent().getSpan(); IntPair span2 = candidates.get(o2).getConstituent().getSpan(); int start1 = span1.getFirst(); int start2 = span2.getFirst(); if (start1 < start2) return -1; else if (start1 == start2) return 0; else return 1; } });
/** * We want to reuse any constituent with the same label and token span and attributes. The * equals method checks all kinds of stuff, in going and out going relations, which are changing * as we construct the view. * @param c the constituent. * @return the disambiguation key for constituents. */ private String constituentDisambiguationKey(Constituent c) { StringBuffer sb = new StringBuffer(); sb.append(c.getLabel()); sb.append(':'); sb.append(c.getSpan().getFirst()); sb.append(':'); sb.append(c.getSpan().getSecond()); return c.getLabel()+":"+c.getStartSpan(); }
@RequestMapping(value = "/gethtml", method = RequestMethod.POST) @ResponseStatus(value = HttpStatus.OK) @ResponseBody public String gethtml(@RequestParam(value = "sentids[]", required = true) String[] sentids, String query, Model model, HttpSession hs) throws Exception { SessionData sd = new SessionData(hs); String ret = ""; for(String sentid : sentids){ Constituent sent = sd.cache.getSentence(sentid); String html = HtmlGenerator.getHTMLfromTA(sent.getTextAnnotation(), sent.getSpan(), getSentId(sent), query, sd.dict, sd.showdefs, sd.showroman, false); ret += html + "\n<br />"; } return ret; }
public String getStrippedNotation(Constituent c) { if (c == null) return "NULL"; String notation = c.getLabel().split("-")[0]; if (NERlexicalise) notation += "-" + getNamedEntityTag(c); if (POSlexicalise) { notation += "-"; IntPair span = c.getSpan(); TextAnnotation ta = c.getTextAnnotation(); for (int tokenId = span.getFirst(); tokenId < span.getSecond(); tokenId++) notation += " " + POSUtils.getPOS(ta, tokenId); } return notation; }
public String getStrippedNotation(Constituent c) { if (c == null) return "NULL"; String notation = c.getLabel().split("-")[0]; if (NERlexicalise) notation += "-" + getNamedEntityTag(c); if (POSlexicalise) { notation += "-"; IntPair span = c.getSpan(); TextAnnotation ta = c.getTextAnnotation(); for (int tokenId = span.getFirst(); tokenId < span.getSecond(); tokenId++) notation += " " + POSUtils.getPOS(ta, tokenId); } return notation; }
public TokenLabelView getView(SenseManager manager, TextAnnotation ta) { String viewName = SenseManager.getPredictedViewName(); TokenLabelView view = new TokenLabelView(viewName, VerbSenseConstants.systemIdentifier, ta, 1.0); for (SenseStructure y : this.ys) { SenseInstance senseInstance = y.getInstance(); IntPair predicateSpan = senseInstance.getConstituent().getSpan(); String sense = manager.getSense(y.getLabel()); view.addTokenLabel(predicateSpan.getFirst(), sense, 1.0); } return view; } }
public TokenLabelView getView(SenseManager manager, TextAnnotation ta) { String viewName = SenseManager.getPredictedViewName(); TokenLabelView view = new TokenLabelView(viewName, VerbSenseConstants.systemIdentifier, ta, 1.0); for (SenseStructure y : this.ys) { SenseInstance senseInstance = y.getInstance(); IntPair predicateSpan = senseInstance.getConstituent().getSpan(); String sense = manager.getSense(y.getLabel()); view.addTokenLabel(predicateSpan.getFirst(), sense, 1.0); } return view; } }