@Override public List<Constituent> transform(Constituent input) { TextAnnotation ta = input.getTextAnnotation(); return getObject(input, getDependencyView(ta, CHARNIAK_DEPENDENCIES), null); }
@Override public List<Constituent> transform(Constituent input) { TextAnnotation ta = input.getTextAnnotation(); return getObject(input, getDependencyView(ta, STANFORD_DEPENDENCIES), null); }
@Override public List<Constituent> transform(Constituent input) { TextAnnotation ta = input.getTextAnnotation(); return getObject(input, getDependencyView(ta, BERKELEY_DEPENDENCIES), null); }
@Override public List<Constituent> transform(Constituent c) { TextAnnotation ta = c.getTextAnnotation(); TreeView dependency = (TreeView) ta.getView(ViewNames.DEPENDENCY); return Collections.singletonList(getHead(c, dependency)); }
@Override public List<Constituent> transform(Constituent input) { TreeView dependency = (TreeView) input.getTextAnnotation().getView( ViewNames.DEPENDENCY_STANFORD); return getGovernor(input, dependency); }
@Override public List<Constituent> transform(Constituent c) { TextAnnotation ta = c.getTextAnnotation(); TreeView dependency = (TreeView) ta.getView(ViewNames.DEPENDENCY); return Collections.singletonList(getHead(c, dependency)); }
@Override public List<Constituent> transform(Constituent c) { TextAnnotation ta = c.getTextAnnotation(); TreeView dependency = (TreeView) ta.getView(ViewNames.DEPENDENCY_STANFORD); return Collections.singletonList(getHead(c, dependency)); }
@Override public List<Constituent> transform(Constituent input) { TreeView dependency = (TreeView) input.getTextAnnotation().getView(ViewNames.DEPENDENCY); return getGovernor(input, dependency); }
@Override public List<Constituent> transform(Constituent input) { TreeView dependency = (TreeView) input.getTextAnnotation().getView(ViewNames.DEPENDENCY); return getObject(input, dependency, "obj"); }
@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<>(); }
@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) { return Collections.singletonList(new Constituent("", "", input.getTextAnnotation(), input.getEndSpan() - 1, input.getEndSpan())); }
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; }
@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); }
/** * 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) { 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 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 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); }