public void addTokenAttribute(int tokenId, String attributeKey, String attributeValue) throws Exception { Constituent c = getConstituentAtToken(tokenId); if (c == null) throw new Exception("Trying to add attribute to non-existent constituent at token " + tokenId); c.addAttribute(attributeKey, attributeValue); }
public void addTokenAttribute(int tokenId, String attributeKey, String attributeValue) throws Exception { Constituent c = getConstituentAtToken(tokenId); if (c == null) throw new Exception("Trying to add attribute to non-existent constituent at token " + tokenId); c.addAttribute(attributeKey, attributeValue); }
protected static void copyAttributesToConstituent(Span span, Constituent newConstituent) { for (String attributeKey : span.getAttributes().keySet()) { newConstituent.addAttribute(attributeKey, span.getAttributes().get(attributeKey)); } } }
protected static void copyAttributesToConstituent(Span span, Constituent newConstituent) { for (String attributeKey : span.getAttributes().keySet()) { newConstituent.addAttribute(attributeKey, span.getAttributes().get(attributeKey)); } } }
protected static void copyAttributesToConstituent(Span span, Constituent newConstituent) { for (String attributeKey : span.getAttributes().keySet()) { newConstituent.addAttribute(attributeKey, span.getAttributes().get(attributeKey)); } } }
@Override public Constituent createPredicate(TextAnnotation ta, String viewName, List<Tree<Pair<String, IntPair>>> yield) { Tree<Pair<String, IntPair>> l = yield.get(predicateTerminal); int start = l.getLabel().getSecond().getFirst(); Constituent predicate = new Constituent("Predicate", viewName, ta, start, start + 1); predicate.addAttribute(PropbankReader.LemmaIdentifier, lemma); predicate.addAttribute(PropbankReader.SenseIdentifier, sense); return predicate; }
@Override public Constituent createPredicate(TextAnnotation ta, String viewName, List<Tree<Pair<String, IntPair>>> yield) { Tree<Pair<String, IntPair>> l = yield.get(predicateTerminal); int start = l.getLabel().getSecond().getFirst(); Constituent predicate = new Constituent("Predicate", viewName, ta, start, start + 1); predicate.addAttribute(PropbankReader.LemmaIdentifier, lemma); predicate.addAttribute(PropbankReader.SenseIdentifier, sense); return predicate; }
public static void addHeadAttributes(Constituent head, Gazetteers gazetteers, BrownClusters brownClusters, WordNetManager wordnet){ View tokenView = head.getTextAnnotation().getView(ViewNames.TOKENS); for (int i = head.getStartSpan(); i < head.getEndSpan(); i++) { head.addAttribute("GAZ" + i, ((FlatGazetteers) gazetteers).annotateConstituent(tokenView.getConstituentsCoveringToken(i).get(0), false)); head.addAttribute("BC" + i, brownClusters.getPrefixesCombined(tokenView.getConstituentsCoveringToken(i).get(0).toString())); } head.addAttribute("GAZ", ((FlatGazetteers) gazetteers).annotatePhrase(head)); }
private static Constituent createConstituentGivenMention(Annotation document, CorefChain chain, CorefChain.CorefMention m, TextAnnotation ta) { Pair<Integer, Integer> mentionCharSpan = getCharIntervalFromCorefMention(document, m.sentNum, m.startIndex, m.endIndex); List<Constituent> overlappingCons = ta.getView(ViewNames.TOKENS).getConstituentsOverlappingCharSpan(mentionCharSpan.getFirst(), mentionCharSpan.getSecond()); int startIndex = overlappingCons.stream().min(Comparator.comparing(Constituent::getStartSpan)).get().getStartSpan(); int endIndex = overlappingCons.stream().max(Comparator.comparing(Constituent::getEndSpan)).get().getEndSpan(); Constituent c = new Constituent(String.valueOf(chain.getChainID()), viewName, ta, startIndex, endIndex); c.addAttribute("animacy", m.animacy.toString()); c.addAttribute("number", m.number.toString()); c.addAttribute("gender", m.gender.toString()); c.addAttribute("mentionType", m.mentionType.toString()); return c; } }
public static void addHeadAttributes(Constituent head, Gazetteers gazetteers, BrownClusters brownClusters, WordNetManager wordnet){ View tokenView = head.getTextAnnotation().getView(ViewNames.TOKENS); for (int i = head.getStartSpan(); i < head.getEndSpan(); i++) { head.addAttribute("GAZ" + i, ((FlatGazetteers) gazetteers).annotateConstituent(tokenView.getConstituentsCoveringToken(i).get(0), false)); head.addAttribute("BC" + i, brownClusters.getPrefixesCombined(tokenView.getConstituentsCoveringToken(i).get(0).toString())); } head.addAttribute("GAZ", ((FlatGazetteers) gazetteers).annotatePhrase(head)); }
public static void addHeadAttributes(Constituent head, Gazetteers gazetteers, BrownClusters brownClusters, WordNetManager wordnet){ View tokenView = head.getTextAnnotation().getView(ViewNames.TOKENS); for (int i = head.getStartSpan(); i < head.getEndSpan(); i++) { head.addAttribute("GAZ" + i, ((FlatGazetteers) gazetteers).annotateConstituent(tokenView.getConstituentsCoveringToken(i).get(0), false)); head.addAttribute("BC" + i, brownClusters.getPrefixesCombined(tokenView.getConstituentsCoveringToken(i).get(0).toString())); } head.addAttribute("GAZ", ((FlatGazetteers) gazetteers).annotatePhrase(head)); }
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 List<Constituent> getPredicates(TextAnnotation ta) throws Exception { List<Constituent> list = new ArrayList<>(); for (int i = 0; i < ta.size(); i++) { Option<String> opt = getLemma(ta, i); if (opt.isPresent()) { Constituent c = new Constituent("", "", ta, i, i + 1); c.addAttribute(PredicateArgumentView.LemmaIdentifier, opt.get()); list.add(c); } } return list; }
public List<Constituent> getPredicates(TextAnnotation ta) throws Exception { List<Constituent> list = new ArrayList<>(); for (int i = 0; i < ta.size(); i++) { Option<String> opt = getLemma(ta, i); if (opt.isPresent()) { Constituent c = new Constituent("", "", ta, i, i + 1); c.addAttribute(PredicateArgumentView.LemmaIdentifier, opt.get()); list.add(c); } } return list; }
public List<Constituent> getPredicates(TextAnnotation ta) throws Exception { List<Constituent> list = new ArrayList<>(); for (int i = 0; i < ta.size(); i++) { Option<String> opt = getLemma(ta, i); if (opt.isPresent()) { Constituent c = new Constituent("", "", ta, i, i + 1); c.addAttribute(PredicateArgumentView.LemmaIdentifier, opt.get()); list.add(c); } } return list; }
public Constituent cloneForNewViewWithDestinationLabel(String newViewName, String Dlabel) { Constituent cloneC = new Constituent(this.labelsToScores, Dlabel, this.getConstituentScore(), newViewName, this.getTextAnnotation(), this.getStartSpan(), this.getEndSpan()); for (String k : this.getAttributeKeys()) { cloneC.addAttribute(k, this.getAttribute(k)); } return cloneC; }
public Constituent cloneForNewViewWithDestinationLabel(String newViewName, String Dlabel) { Constituent cloneC = new Constituent(this.labelsToScores, Dlabel, this.getConstituentScore(), newViewName, this.getTextAnnotation(), this.getStartSpan(), this.getEndSpan()); for (String k : this.getAttributeKeys()) { cloneC.addAttribute(k, this.getAttribute(k)); } return cloneC; }
public Constituent cloneForNewView(String newViewName) { Constituent cloneC = new Constituent(this.labelsToScores, this.getLabel(), this.getConstituentScore(), newViewName, this.getTextAnnotation(), this.getStartSpan(), this.getEndSpan()); for (String k : this.getAttributeKeys()) { cloneC.addAttribute(k, this.getAttribute(k)); } return cloneC; }
public Constituent cloneForNewView(String newViewName) { Constituent cloneC = new Constituent(this.labelsToScores, this.getLabel(), this.getConstituentScore(), newViewName, this.getTextAnnotation(), this.getStartSpan(), this.getEndSpan()); for (String k : this.getAttributeKeys()) { cloneC.addAttribute(k, this.getAttribute(k)); } return cloneC; }
@Override protected void addView(TextAnnotation ta) throws AnnotatorException { assert ta.hasView(ViewNames.SENTENCE): "Sentences view didn't find . . . "; List<Constituent> sentences = ta.getView(ViewNames.SENTENCE).getConstituents(); View vu = new View(viewName, "ClausIEAnnotator", ta, 1.0); assert sentences.size() == ta.getNumberOfSentences(); for(Constituent sent : sentences) { String[] clausieResults = ClausieSplitter.split(sent.getSurfaceForm()); Constituent sentenceCons = new Constituent("sent-" + sent.getSentenceId(), viewName, ta, sent.getStartSpan(), sent.getEndSpan()); int propId = 0; for(String clausieSent : clausieResults) { sentenceCons.addAttribute("clauseIe:" + propId, clausieSent); propId++; } vu.addConstituent(sentenceCons); } ta.addView(viewName, vu); } }