/** * A little convenience function. * * @param sent * @return */ public static String getSentId(Constituent sent) { return sent.getTextAnnotation().getId() + ":" + sent.getSentenceId(); }
@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 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<>(); }
Constituent target = r.getTarget(); TextAnnotation ta = source.getTextAnnotation(); int sentenceStart = ta.getSentence(source.getSentenceId()).getStartSpan(); int sentenceEnd = ta.getSentence(source.getSentenceId()).getEndSpan(); if (source.getStartSpan() - sentenceStart > 0){ ret_features.add("fwM1_" + ta.getToken(source.getStartSpan() - 1));
if (predicateToken + 1 < ta.getSentence(predicate.getSentenceId()) .getEndSpan()) { String nextToken = WordHelpers.getLemma(ta, predicateToken + 1);
List<Constituent> source_parsed_list = parse.getConstituentsCoveringToken(source_head.getStartSpan()); List<Constituent> target_parsed_list = parse.getConstituentsCoveringToken(target_head.getStartSpan()); if (source.getSentenceId() == target.getSentenceId()){ try { if (source_parsed_list.size() != 0 && target_parsed_list.size() != 0) {
if (source.getSentenceId() == target.getSentenceId()){ try { if (source_parsed_list.size() != 0 && target_parsed_list.size() != 0) {
@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); } }