@Override public Boolean transform(Constituent input) { return input.getEndSpan() <= c.getStartSpan(); } };
@Override public Boolean transform(Constituent input) { int s1 = c.getStartSpan(); int e1 = c.getEndSpan(); int s2 = input.getStartSpan(); int e2 = input.getEndSpan(); return s2 < e1 && s1 < e2; } };
@Override public Boolean transform(Constituent arg0) { return c.getStartSpan() == arg0.getEndSpan(); } };
@Override public List<Constituent> transform(Constituent input) { return Collections.singletonList(new Constituent("", "", input.getTextAnnotation(), input.getEndSpan() - 1, input.getEndSpan())); }
public Boolean transform(final Constituent input) { return input.getStartSpan() == c.getStartSpan() && input.getEndSpan() == c.getEndSpan(); } };
@Override public Boolean transform(Constituent input) { return input.getStartSpan() >= c.getEndSpan(); } };
public Boolean transform(final Constituent input) { return (c.getStartSpan() <= input.getStartSpan() && c.getEndSpan() >= input .getEndSpan()) && (c.getStartSpan() != input.getStartSpan() || c.getEndSpan() != input .getEndSpan()); } };
public List<Constituent> getSpanLabels(int start, int end) { List<Constituent> labeledConstituents = new ArrayList<>(); for (Constituent c : this.constituents) { if (c.getStartSpan() >= start && c.getEndSpan() < end) { labeledConstituents.add(c); } } return labeledConstituents; }
/** * Get the constituents which cover the input constituent {@code c}. * * @param c A constituent, not necessarily of this text annotation. * @return A list of constituents, which cover the same tokens as the input */ public List<Constituent> getConstituentsCovering(Constituent c) { return this.getConstituentsCoveringSpan(c.getStartSpan(), c.getEndSpan()); }
@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; }
/** * Get the labels of the constituents covered by the input constituent {@code c} * * @param c A constituent, not necessarily of this text annotation. * @return A list of labels of constituents, which cover the same tokens as the input */ public List<String> getLabelsCovering(Constituent c) { return this.getLabelsCoveringSpan(c.getStartSpan(), c.getEndSpan()); }
@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) { 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<>(); }
@Override public Set<Feature> getFeatures(Constituent c) throws EdisonException { SpanLabelView chunks = (SpanLabelView) c.getTextAnnotation().getView(viewName); List<Constituent> list = SpanLabelsHelper.getConstituentsInBetween(chunks, c.getStartSpan(), c.getEndSpan()); Collections.sort(list, TextAnnotationUtilities.constituentStartComparator); return FeatureNGramUtility.getLabelNgramsUnordered(list, ngramLength); }
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 String getLemma(Constituent c) { if (c.hasAttribute(PredicateArgumentView.LemmaIdentifier)) { return c.getAttribute(PredicateArgumentView.LemmaIdentifier); } else if (c.getTextAnnotation().hasView(ViewNames.LEMMA)) { return WordHelpers.getLemma(c.getTextAnnotation(), c.getEndSpan() - 1); } else return null; }
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 static Tree<Pair<String, IntPair>> getTokenIndexedCleanedParseTreeNodeCovering( Constituent c, String parseViewName) { TextAnnotation ta = c.getTextAnnotation(); Tree<String> tree = getParseTree(parseViewName, ta, ta.getSentenceId(c)); int start = c.getStartSpan(); int end = c.getEndSpan(); tree = ParseUtils.snipNullNodes(tree); tree = ParseUtils.stripFunctionTags(tree); tree = ParseUtils.stripIndexReferences(tree); return getTokenIndexedTreeCovering(tree, start, end); }
public static Tree<Pair<String, IntPair>> getTokenIndexedCleanedParseTreeNodeCovering( Constituent c, String parseViewName) { TextAnnotation ta = c.getTextAnnotation(); Tree<String> tree = getParseTree(parseViewName, ta, ta.getSentenceId(c)); int start = c.getStartSpan(); int end = c.getEndSpan(); tree = ParseUtils.snipNullNodes(tree); tree = ParseUtils.stripFunctionTags(tree); tree = ParseUtils.stripIndexReferences(tree); return getTokenIndexedTreeCovering(tree, start, end); }