@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(); } };
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; }
@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<>(); }
/** * Check if the Constituent is a start of a sentence * The size of the Constituent should be 1 */ public static String isSentenceStart (Constituent c){ Sentence sentence = c.getTextAnnotation().getSentenceFromToken(c.getStartSpan()); int sentenceStart = sentence.getStartSpan(); if (c.getStartSpan() == sentenceStart){ return "1"; } return "0"; }
@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<>(); }
/** * 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()); }
protected void addGoldView(TextAnnotation ta, List<String> labels) { TokenLabelView posView = new TokenLabelView(viewName, ta); List<Constituent> constituents = ta.getView(ViewNames.TOKENS).getConstituents(); for (int i = 0; i < constituents.size(); ++i) { Constituent constituent = (Constituent) constituents.get(i); posView.addTokenLabel(constituent.getStartSpan(), labels.get(i), 1.0D); } ta.addView(viewName, posView); } }
@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 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)); }
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); }