public static void annotateChunk(CoreMap annotation, Class newAnnotationKey, Class aggrKey, CoreMapAttributeAggregator aggregator) { Object v = aggregator.aggregate(aggrKey, annotation.get(CoreAnnotations.TokensAnnotation.class)); annotation.set(newAnnotationKey, v); }
public boolean extractAnnotation(Env env, List<? extends CoreMap> source) { return extractAnnotation(source, CoreMapAttributeAggregator.getDefaultAggregators()); }
private CoreMap createMergedChunk(int groupStart, int groupEnd) { CoreMap merged = null; /* if (annotation != null) { // Take start and end merged = ChunkAnnotationUtils.getMergedChunk(elements, annotation.get(CoreAnnotations.TextAnnotation.class), groupStart, groupEnd); } */ if (merged == null) { // Okay, have to go through these one by one and merge them merged = ChunkAnnotationUtils.getMergedChunk(elements, groupStart, groupEnd, CoreMapAttributeAggregator.getDefaultAggregators()); } return merged; }
assert(false); Object value = entry.getValue().aggregate(entry.getKey(), chunkList.subList(chunkIndexStart, chunkIndexEnd)); newChunk.set(entry.getKey(), value);
private CoreMap createMergedChunk(int groupStart, int groupEnd) { CoreMap merged = null; /* if (annotation != null) { // Take start and end merged = ChunkAnnotationUtils.getMergedChunk(elements, annotation.get(CoreAnnotations.TextAnnotation.class), groupStart, groupEnd); } */ if (merged == null) { // Okay, have to go through these one by one and merge them merged = ChunkAnnotationUtils.getMergedChunk(elements, groupStart, groupEnd, CoreMapAttributeAggregator.getDefaultAggregators()); } return merged; }
for (CoreMap mention : mentions) { List<CoreLabel> mentionTokens = mention.get(CoreAnnotations.TokensAnnotation.class); String name = (String) CoreMapAttributeAggregator.FIRST_NON_NIL.aggregate( nerNormalizedCoreAnnotationClass, mentionTokens); if (name == null) { Timex timex = (Timex) CoreMapAttributeAggregator.FIRST_NON_NIL.aggregate( TimeAnnotations.TimexAnnotation.class, mentionTokens); if (timex != null) {
if (v2.doubleValue() > v1.doubleValue()) { CoreMap newChunk = ChunkAnnotationUtils.getMergedChunk(numerizedTokens, matcher.start(), matcher.end(), CoreMapAttributeAggregator.getDefaultAggregators()); newChunk.set(CoreAnnotations.NumericCompositeTypeAnnotation.class, "NUMBER_RANGE"); Pair<Number,Number> range = new Pair<Number,Number>(v1,v2);
public static void annotateChunk(CoreMap annotation, Class newAnnotationKey, Class aggrKey, CoreMapAttributeAggregator aggregator) { Object v = aggregator.aggregate(aggrKey, annotation.get(CoreAnnotations.TokensAnnotation.class)); annotation.set(newAnnotationKey, v); }
if (v2.doubleValue() > v1.doubleValue()) { CoreMap newChunk = ChunkAnnotationUtils.getMergedChunk(numerizedTokens, matcher.start(), matcher.end(), CoreMapAttributeAggregator.getDefaultAggregators()); newChunk.set(CoreAnnotations.NumericCompositeTypeAnnotation.class, "NUMBER_RANGE"); Pair<Number,Number> range = new Pair(v1,v2);
/** * Create chunk that is merged from chunkIndexStart to chunkIndexEnd (exclusive) * @param chunkList - List of chunks * @param chunkIndexStart - Index of first chunk to merge * @param chunkIndexEnd - Index of last chunk to merge (exclusive) * @param aggregators - Aggregators * @return new merged chunk */ public static CoreMap getMergedChunk(List<? extends CoreMap> chunkList, int chunkIndexStart, int chunkIndexEnd, Map<Class, CoreMapAttributeAggregator> aggregators) { CoreMap newChunk = new Annotation(""); for (Map.Entry<Class,CoreMapAttributeAggregator> entry:aggregators.entrySet()) { Object value = entry.getValue().aggregate(entry.getKey(), chunkList.subList(chunkIndexStart, chunkIndexEnd)); newChunk.set(entry.getKey(), value); } return newChunk; }
public CoreMap extractAnnotation(List<? extends CoreMap> source) { annotation = ChunkAnnotationUtils.getMergedChunk(source, chunkOffsets.getBegin(), chunkOffsets.getEnd(), CoreMapAttributeAggregator.getDefaultAggregators()); charOffsets = Interval.toInterval(annotation.get(CoreAnnotations.CharacterOffsetBeginAnnotation.class), annotation.get(CoreAnnotations.CharacterOffsetEndAnnotation.class), Interval.INTERVAL_OPEN_END); tokenOffsets = Interval.toInterval(annotation.get(CoreAnnotations.TokenBeginAnnotation.class), annotation.get(CoreAnnotations.TokenEndAnnotation.class), Interval.INTERVAL_OPEN_END); annotation.set(Annotation.class, this); annotation.set(TimeExpression.ChildrenAnnotation.class, source.subList(chunkOffsets.getBegin(), chunkOffsets.getEnd())); text = annotation.get(CoreAnnotations.TextAnnotation.class); temporal = temporalFunc.apply(annotation); return annotation; }
/** * Create chunk that is merged from chunkIndexStart to chunkIndexEnd (exclusive) * @param chunkList - List of chunks * @param chunkIndexStart - Index of first chunk to merge * @param chunkIndexEnd - Index of last chunk to merge (exclusive) * @param aggregators - Aggregators * @return new merged chunk */ public static CoreMap getMergedChunk(List<? extends CoreMap> chunkList, int chunkIndexStart, int chunkIndexEnd, Map<Class, CoreMapAttributeAggregator> aggregators) { CoreMap newChunk = new Annotation(""); for (Map.Entry<Class,CoreMapAttributeAggregator> entry:aggregators.entrySet()) { if (chunkIndexEnd > chunkList.size()) { assert(false); } Object value = entry.getValue().aggregate(entry.getKey(), chunkList.subList(chunkIndexStart, chunkIndexEnd)); newChunk.set(entry.getKey(), value); } return newChunk; }
public static void annotateChunk(CoreMap annotation, Class newAnnotationKey, Class aggrKey, CoreMapAttributeAggregator aggregator) { Object v = aggregator.aggregate(aggrKey, annotation.get(CoreAnnotations.TokensAnnotation.class)); annotation.set(newAnnotationKey, v); }
public static void annotateChunk(CoreMap annotation, Class newAnnotationKey, Class aggrKey, CoreMapAttributeAggregator aggregator) { Object v = aggregator.aggregate(aggrKey, annotation.get(CoreAnnotations.TokensAnnotation.class)); annotation.set(newAnnotationKey, v); }
public static void annotateChunk(CoreMap annotation, Class newAnnotationKey, Class aggrKey, CoreMapAttributeAggregator aggregator) { Object v = aggregator.aggregate(aggrKey, annotation.get(CoreAnnotations.TokensAnnotation.class)); annotation.set(newAnnotationKey, v); }
assert(false); Object value = entry.getValue().aggregate(entry.getKey(), chunkList.subList(chunkIndexStart, chunkIndexEnd)); newChunk.set(entry.getKey(), value);
assert(false); Object value = entry.getValue().aggregate(entry.getKey(), chunkList.subList(chunkIndexStart, chunkIndexEnd)); newChunk.set(entry.getKey(), value);
for (CoreMap mention : mentions) { List<CoreLabel> mentionTokens = mention.get(CoreAnnotations.TokensAnnotation.class); String name = (String) CoreMapAttributeAggregator.FIRST_NON_NIL.aggregate( nerNormalizedCoreAnnotationClass, mentionTokens); if (name == null) { Timex timex = (Timex) CoreMapAttributeAggregator.FIRST_NON_NIL.aggregate( TimeAnnotations.TimexAnnotation.class, mentionTokens); if (timex != null) {