@Override public Set<Feature> getWordFeatures(TextAnnotation ta, int wordPosition) throws EdisonException { return fex.getFeatures(new Constituent("", "", ta, wordPosition, wordPosition + 1)); } };
@Override public Set<Feature> getWordFeatures(TextAnnotation ta, int wordPosition) throws EdisonException { return fex.getFeatures(new Constituent("", "", ta, wordPosition, wordPosition + 1)); } };
@Override public Set<Feature> getWordFeatures(TextAnnotation ta, int wordPosition) throws EdisonException { return fex.getFeatures(new Constituent("", "", ta, wordPosition, wordPosition + 1)); } };
@Override public List<Constituent> transform(Constituent input) { int tokenId = input.getStartSpan(); if (tokenId > 0) { Constituent c = new Constituent("", "", input.getTextAnnotation(), tokenId - 1, tokenId); return Collections.singletonList(addPointerToSource(input, c)); } else return new ArrayList<>(); }
/** * Makes a new constituent spanning {@code start} to {@code end} with the label * {@code constituentLabel} and score {@code constituentScore}. */ private Constituent createNewConstituent(int start, int end, String constituentLabel, double constituentScore) { return new Constituent(constituentLabel, constituentScore, this.getViewName(), this.getTextAnnotation(), start, end); }
@Override public List<Constituent> transform(Constituent input) { List<Constituent> list = new ArrayList<>(); TextAnnotation ta = input.getTextAnnotation(); for (int i = input.getStartSpan(); i < input.getEndSpan(); i++) { list.add(new Constituent("", "", ta, i, i + 1)); } return list; }
@Override public List<Constituent> transform(Constituent input) { List<Constituent> list = new ArrayList<>(); TextAnnotation ta = input.getTextAnnotation(); for (int i = input.getStartSpan(); i < input.getEndSpan(); i++) { list.add(new Constituent("", "", ta, i, i + 1)); } return list; }
public static Constituent isBigramPrep(TextAnnotation ta, int tokenId, String viewName) { String word = WordHelpers.getWord(ta, tokenId); if (tokenId < ta.size() - 1) { String nextWord = WordHelpers.getWord(ta, tokenId + 1); if (mwPrepositionsList.contains(word + " " + nextWord)) return new Constituent("", viewName, ta, tokenId, tokenId + 2); } return null; }
@Override public List<Constituent> transform(Constituent input) { return Collections.singletonList(new Constituent("", "", input.getTextAnnotation(), input.getEndSpan() - 1, input.getEndSpan())); }
private static Constituent getConstituent(String label, Pair<Integer, Integer> tokenSpan, CoreMap sentence, TextAnnotation ta) { List<CoreLabel> tokens = sentence.get(CoreAnnotations.TokensAnnotation.class); int extentCharStart = tokens.get(tokenSpan.first()).beginPosition(); int extentCharEnd = tokens.get(tokenSpan.second()).endPosition() - 1; List<Constituent> extentCons = ta.getView(ViewNames.TOKENS).getConstituentsOverlappingCharSpan(extentCharStart, extentCharEnd); int startIndex = extentCons.stream().min(Comparator.comparing(Constituent::getStartSpan)).get().getStartSpan(); int endIndex = extentCons.stream().max(Comparator.comparing(Constituent::getEndSpan)).get().getEndSpan(); return new Constituent(label, viewName, ta, startIndex, endIndex); } }
@Override public List<Constituent> transform(Constituent input) { return Collections.singletonList(new Constituent("", "", input.getTextAnnotation(), input.getStartSpan(), input.getStartSpan() + 1)); }
@Override public List<Constituent> transform(Constituent input) { return Collections.singletonList(new Constituent("", "", input.getTextAnnotation(), input.getStartSpan(), input.getStartSpan() + 1)); }
public static Constituent getPredictedMentionHead(Constituent c){ return new Constituent(c.getLabel(), "HEAD", c.getTextAnnotation(), Integer.parseInt(c.getAttribute("EntityHeadStartSpan")), Integer.parseInt(c.getAttribute("EntityHeadEndSpan"))); }
@Override public List<Constituent> transform(Constituent input) { TextAnnotation ta = input.getTextAnnotation(); Constituent ce = new Constituent("", "", ta, input.getEndSpan() - 1, input.getEndSpan()); Constituent cs = new Constituent("", "", ta, input.getStartSpan(), input.getStartSpan() + 1); new Relation("", cs, ce, 0); return Collections.singletonList(ce); }
@Override public List<Constituent> transform(Constituent input) { TextAnnotation ta = input.getTextAnnotation(); Constituent ce = new Constituent("", "", ta, input.getEndSpan() - 1, input.getEndSpan()); Constituent cs = new Constituent("", "", ta, input.getStartSpan(), input.getStartSpan() + 1); new Relation("", cs, ce, 0); return Collections.singletonList(ce); }
@Override public List<Constituent> transform(Constituent input) { TextAnnotation ta = input.getTextAnnotation(); Constituent ce = new Constituent("", "", ta, input.getEndSpan() - 1, input.getEndSpan()); Constituent cs = new Constituent("", "", ta, input.getStartSpan(), input.getStartSpan() + 1); new Relation("", cs, ce, 0); return Collections.singletonList(ce); }
public static Constituent isTrigramPrep(TextAnnotation ta, int tokenId, String viewName) { String word = WordHelpers.getWord(ta, tokenId); if (tokenId < ta.size() - 2) { String nextWord = WordHelpers.getWord(ta, tokenId + 1); String nextNextWord = WordHelpers.getWord(ta, tokenId + 2); if (mwPrepositionsList.contains(word + " " + nextWord + " " + nextNextWord)) return new Constituent("", viewName, ta, tokenId, tokenId + 3); } return null; }
@Override public List<Constituent> transform(Constituent input) { int tokenId = input.getEndSpan(); TextAnnotation ta = input.getTextAnnotation(); Sentence sentence = ta.getSentence(input.getSentenceId()); if (tokenId < sentence.size()) { Constituent c = new Constituent("", "", ta, tokenId, tokenId + 1); return Collections.singletonList(addPointerToSource(input, c)); } else return new ArrayList<>(); }
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; }
protected static Constituent getNewConstituentForSpan(String label, String viewName, TextAnnotation ta, Span span) { int start = ta.getTokenIdFromCharacterOffset(span.getStart()); int end = ta.getTokenIdFromCharacterOffset(span.getEnding() - 1) + 1; Constituent constituent = new Constituent(label, viewName, ta, start, end); if (span.isSetAttributes()) { copyAttributesToConstituent(span, constituent); } return constituent; }