@Override public void finalize(CoreMap docAnnotation) { docAnnotation.remove(TimeExpression.TimeIndexAnnotation.class); }
/** * Annotate a document (which is usually just a sentence). */ public void annotate(StanfordCoreNLP pipeline, Annotation ann) { if (ann.get(CoreAnnotations.SentencesAnnotation.class) == null) { pipeline.annotate(ann); } else { if (ann.get(CoreAnnotations.SentencesAnnotation.class).size() == 1) { CoreMap sentence = ann.get(CoreAnnotations.SentencesAnnotation.class).get(0); for (CoreLabel token : sentence.get(CoreAnnotations.TokensAnnotation.class)) { token.remove(NaturalLogicAnnotations.OperatorAnnotation.class); token.remove(NaturalLogicAnnotations.PolarityAnnotation.class); } sentence.remove(NaturalLogicAnnotations.RelationTriplesAnnotation.class); sentence.remove(NaturalLogicAnnotations.EntailedSentencesAnnotation.class); sentence.remove(SemanticGraphCoreAnnotations.BasicDependenciesAnnotation.class); sentence.remove(SemanticGraphCoreAnnotations.EnhancedDependenciesAnnotation.class); sentence.remove(SemanticGraphCoreAnnotations.EnhancedPlusPlusDependenciesAnnotation.class); pipeline.annotate(ann); } } }
private void cleanupTags(CoreMap cm, Map<Object, Boolean> cleaned) { cm.remove(Tags.TagsAnnotation.class); for (Class key:cm.keySet()) { Object obj = cm.get(key); if (!cleaned.containsKey(obj)) { cleaned.put(obj, false); if (obj instanceof CoreMap) { cleanupTags((CoreMap) obj, cleaned); } else if (obj instanceof Collection) { cleanupTags((Collection) obj, cleaned); } cleaned.put(obj, true); } } }
cm.set(key, stack.peek().second); } else { cm.remove(key);
new ArrayList<>(new HashSet<>(extractions))); // uniq the extractions if (stripEntailments) { sentence.remove(NaturalLogicAnnotations.EntailedSentencesAnnotation.class);
w.set(CoreAnnotations.PositionAnnotation.class, Integer.toString(pos)); after = StringUtils.getNotNullString(w.get(CoreAnnotations.AfterAnnotation.class)); w.remove(CoreAnnotations.AfterAnnotation.class); last = w;
public Document nextDoc() throws Exception { InputDoc input = reader.nextDoc(); if (input == null) { return null; } if (!CorefProperties.useConstituencyParse(props)) { for (CoreMap sentence : input.annotation.get(CoreAnnotations.SentencesAnnotation.class)) { sentence.remove(TreeCoreAnnotations.TreeAnnotation.class); } } getStanfordCoreNLP(props).annotate(input.annotation); if (CorefProperties.conll(props)) { input.annotation.set(CoreAnnotations.UseMarkedDiscourseAnnotation.class, true); } return makeDocument(input); }
IN newFL = tokenFactory.makeToken(fi); String guess = classIndex.get(seq[pos]); fi.remove(CoreAnnotations.AnswerAnnotation.class); // because fake answers will get
if (!Constants.USE_GOLD_PARSES && !replicateCoNLL) { sentence.remove(TreeCoreAnnotations.TreeAnnotation.class); } else { Tree tree = sentence.get(TreeCoreAnnotations.TreeAnnotation.class);
@Override public void finalize(CoreMap docAnnotation) { docAnnotation.remove(TimeExpression.TimeIndexAnnotation.class); }
public void finalize(CoreMap docAnnotation) { docAnnotation.remove(TimeExpression.TimeIndexAnnotation.class); }
private void cleanupTags(CoreMap cm, Map<Object, Boolean> cleaned) { cm.remove(Tags.TagsAnnotation.class); for (Class key:cm.keySet()) { Object obj = cm.get(key); if (!cleaned.containsKey(obj)) { cleaned.put(obj, false); if (obj instanceof CoreMap) { cleanupTags((CoreMap) obj, cleaned); } else if (obj instanceof Collection) { cleanupTags((Collection) obj, cleaned); } cleaned.put(obj, true); } } }
private void cleanupTags(CoreMap cm, Map<Object, Boolean> cleaned) { cm.remove(Tags.TagsAnnotation.class); for (Class key:cm.keySet()) { Object obj = cm.get(key); if (!cleaned.containsKey(obj)) { cleaned.put(obj, false); if (obj instanceof CoreMap) { cleanupTags((CoreMap) obj, cleaned); } else if (obj instanceof Collection) { cleanupTags((Collection) obj, cleaned); } cleaned.put(obj, true); } } }
private void cleanupTags(CoreMap cm, Map<Object, Boolean> cleaned) { cm.remove(Tags.TagsAnnotation.class); for (Class key:cm.keySet()) { Object obj = cm.get(key); if (!cleaned.containsKey(obj)) { cleaned.put(obj, false); if (obj instanceof CoreMap) { cleanupTags((CoreMap) obj, cleaned); } else if (obj instanceof Collection) { cleanupTags((Collection) obj, cleaned); } cleaned.put(obj, true); } } }
w.set(CoreAnnotations.PositionAnnotation.class, Integer.toString(pos)); after = StringUtils.getNotNullString(w.get(CoreAnnotations.AfterAnnotation.class)); w.remove(CoreAnnotations.AfterAnnotation.class); last = w;
w.set(CoreAnnotations.PositionAnnotation.class, Integer.toString(pos)); after = StringUtils.getNotNullString(w.get(CoreAnnotations.AfterAnnotation.class)); w.remove(CoreAnnotations.AfterAnnotation.class); last = w;
public Document nextDoc() throws Exception { InputDoc input = reader.nextDoc(); if (input == null) { return null; } if (!CorefProperties.useConstituencyParse(props)) { for (CoreMap sentence : input.annotation.get(CoreAnnotations.SentencesAnnotation.class)) { sentence.remove(TreeCoreAnnotations.TreeAnnotation.class); } } getStanfordCoreNLP(props).annotate(input.annotation); if (CorefProperties.conll(props)) { input.annotation.set(CoreAnnotations.UseMarkedDiscourseAnnotation.class, true); } return makeDocument(input); }
public Counter<List<IN>> classifyKBest(List<IN> doc, Class<? extends CoreAnnotation<String>> answerField, int k) { if (doc.isEmpty()) { return new ClassicCounter<List<IN>>(); } // TODO get rid of ObjectBankWrapper // i'm sorry that this is so hideous - JRF ObjectBankWrapper<IN> obw = new ObjectBankWrapper<IN>(flags, null, knownLCWords); doc = obw.processDocument(doc); SequenceModel model = getSequenceModel(doc); KBestSequenceFinder tagInference = new KBestSequenceFinder(); Counter<int[]> bestSequences = tagInference.kBestSequences(model, k); Counter<List<IN>> kBest = new ClassicCounter<List<IN>>(); for (int[] seq : bestSequences.keySet()) { List<IN> kth = new ArrayList<IN>(); int pos = model.leftWindow(); for (IN fi : doc) { IN newFL = tokenFactory.makeToken(fi); String guess = classIndex.get(seq[pos]); fi.remove(AnswerAnnotation.class); // because fake answers will get // added during testing newFL.set(answerField, guess); pos++; kth.add(newFL); } kBest.setCount(kth, bestSequences.getCount(seq)); } return kBest; }
IN newFL = tokenFactory.makeToken(fi); String guess = classIndex.get(seq[pos]); fi.remove(CoreAnnotations.AnswerAnnotation.class); // because
IN newFL = tokenFactory.makeToken(fi); String guess = classIndex.get(seq[pos]); fi.remove(CoreAnnotations.AnswerAnnotation.class); // because fake answers will get