/** * Merge chunks from chunkIndexStart to chunkIndexEnd (exclusive) and replace them in the list. * @param chunkList - List of chunks * @param origText - Text from which to extract chunk text * @param chunkIndexStart - Index of first chunk to merge * @param chunkIndexEnd - Index of last chunk to merge (exclusive) */ public static void mergeChunks(List<CoreMap> chunkList, String origText, int chunkIndexStart, int chunkIndexEnd) { CoreMap newChunk = getMergedChunk(chunkList, origText, chunkIndexStart, chunkIndexEnd, null); int nChunksToRemove = chunkIndexEnd - chunkIndexStart - 1; for (int i = 0; i < nChunksToRemove; i++) { chunkList.remove(chunkIndexStart); } chunkList.set(chunkIndexStart, newChunk); }
public CoreMap merge(List<? extends CoreMap> in, int start, int end) { CoreMap merged = ChunkAnnotationUtils.getMergedChunk(in, start, end, aggregators, tokenFactory); if (mergedKey != null) { merged.set(mergedKey, new ArrayList<>(in.subList(start, end))); } return merged; }
protected Collection<Interval<Integer>> match(List<? extends CoreMap> nodes, int start) { List<Interval<Integer>> matched = new ArrayList<>(); int minEnd = start + minNodes; int maxEnd = nodes.size(); if (maxNodes >= 0 && maxNodes + start < nodes.size()) { maxEnd = maxNodes + start; } for (int end = minEnd; end <= maxEnd; end++) { CoreMap chunk = ChunkAnnotationUtils.getMergedChunk(nodes, start, end, aggregators, null); if (nodePattern.match(chunk)) { matched.add(Interval.toInterval(start, end)); } } return matched; }
/** * Merge chunks from chunkIndexStart to chunkIndexEnd (exclusive) and replace them in the list. * @param chunkList - List of chunks * @param origText - Text from which to extract chunk text * @param chunkIndexStart - Index of first chunk to merge * @param chunkIndexEnd - Index of last chunk to merge (exclusive) */ public static void mergeChunks(List<CoreMap> chunkList, String origText, int chunkIndexStart, int chunkIndexEnd) { CoreMap newChunk = getMergedChunk(chunkList, origText, chunkIndexStart, chunkIndexEnd, null); int nChunksToRemove = chunkIndexEnd - chunkIndexStart - 1; for (int i = 0; i < nChunksToRemove; i++) { chunkList.remove(chunkIndexStart); } chunkList.set(chunkIndexStart, newChunk); }
/** * Merge chunks from chunkIndexStart to chunkIndexEnd (exclusive) and replace them in the list. * @param chunkList - List of chunks * @param origText - Text from which to extract chunk text * @param chunkIndexStart - Index of first chunk to merge * @param chunkIndexEnd - Index of last chunk to merge (exclusive) */ public static void mergeChunks(List<CoreMap> chunkList, String origText, int chunkIndexStart, int chunkIndexEnd) { CoreMap newChunk = getMergedChunk(chunkList, origText, chunkIndexStart, chunkIndexEnd, null); int nChunksToRemove = chunkIndexEnd - chunkIndexStart - 1; for (int i = 0; i < nChunksToRemove; i++) { chunkList.remove(chunkIndexStart); } chunkList.set(chunkIndexStart, newChunk); }
/** * Merge chunks from chunkIndexStart to chunkIndexEnd (exclusive) and replace them in the list * @param chunkList - List of chunks * @param origText - Text from which to extract chunk text * @param chunkIndexStart - Index of first chunk to merge * @param chunkIndexEnd - Index of last chunk to merge (exclusive) */ public static void mergeChunks(List<CoreMap> chunkList, String origText, int chunkIndexStart, int chunkIndexEnd) { CoreMap newChunk = getMergedChunk(chunkList, origText, chunkIndexStart, chunkIndexEnd); int nChunksToRemove = chunkIndexEnd - chunkIndexStart - 1; for (int i = 0; i < nChunksToRemove; i++) { chunkList.remove(chunkIndexStart); } chunkList.set(chunkIndexStart, newChunk); }
/** * Merge chunks from chunkIndexStart to chunkIndexEnd (exclusive) and replace them in the list * @param chunkList - List of chunks * @param origText - Text from which to extract chunk text * @param chunkIndexStart - Index of first chunk to merge * @param chunkIndexEnd - Index of last chunk to merge (exclusive) */ public static void mergeChunks(List<CoreMap> chunkList, String origText, int chunkIndexStart, int chunkIndexEnd) { CoreMap newChunk = getMergedChunk(chunkList, origText, chunkIndexStart, chunkIndexEnd); int nChunksToRemove = chunkIndexEnd - chunkIndexStart - 1; for (int i = 0; i < nChunksToRemove; i++) { chunkList.remove(chunkIndexStart); } chunkList.set(chunkIndexStart, newChunk); }
public CoreMap merge(List<? extends CoreMap> in, int start, int end) { CoreMap merged = ChunkAnnotationUtils.getMergedChunk(in, start, end, aggregators); if (mergedKey != null) { merged.set(mergedKey, new ArrayList<CoreMap>(in.subList(start, end))); } return merged; }
public CoreMap merge(List<? extends CoreMap> in, int start, int end) { CoreMap merged = ChunkAnnotationUtils.getMergedChunk(in, start, end, aggregators, tokenFactory); if (mergedKey != null) { merged.set(mergedKey, new ArrayList<>(in.subList(start, end))); } return merged; }
public CoreMap merge(List<? extends CoreMap> in, int start, int end) { CoreMap merged = ChunkAnnotationUtils.getMergedChunk(in, start, end, aggregators, tokenFactory); if (mergedKey != null) { merged.set(mergedKey, new ArrayList<>(in.subList(start, end))); } return merged; }
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; }
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; }
public CoreMap merge(List<? extends CoreMap> in, int start, int end) { CoreMap merged = ChunkAnnotationUtils.getMergedChunk(in, start, end, aggregators); if (mergedKey != null) { merged.set(mergedKey, new ArrayList<CoreMap>(in.subList(start, end))); } return merged; }
protected Collection<Interval<Integer>> match(List<? extends CoreMap> nodes, int start) { List<Interval<Integer>> matched = new ArrayList<>(); int minEnd = start + minNodes; int maxEnd = nodes.size(); if (maxNodes >= 0 && maxNodes + start < nodes.size()) { maxEnd = maxNodes + start; } for (int end = minEnd; end <= maxEnd; end++) { CoreMap chunk = ChunkAnnotationUtils.getMergedChunk(nodes, start, end, aggregators, null); if (nodePattern.match(chunk)) { matched.add(Interval.toInterval(start, end)); } } return matched; }
protected Collection<Interval<Integer>> match(List<? extends CoreMap> nodes, int start) { List<Interval<Integer>> matched = new ArrayList<>(); int minEnd = start + minNodes; int maxEnd = nodes.size(); if (maxNodes >= 0 && maxNodes + start < nodes.size()) { maxEnd = maxNodes + start; } for (int end = minEnd; end <= maxEnd; end++) { CoreMap chunk = ChunkAnnotationUtils.getMergedChunk(nodes, start, end, aggregators, null); if (nodePattern.match(chunk)) { matched.add(Interval.toInterval(start, end)); } } return matched; }
protected Collection<Interval<Integer>> match(List<? extends CoreMap> nodes, int start) { List<Interval<Integer>> matched = new ArrayList<Interval<Integer>>(); int minEnd = start + minNodes; int maxEnd = nodes.size(); if (maxNodes >= 0 && maxNodes + start < nodes.size()) { maxEnd = maxNodes + start; } for (int end = minEnd; end <= maxEnd; end++) { CoreMap chunk = ChunkAnnotationUtils.getMergedChunk(nodes, start, end, aggregators); if (nodePattern.match(chunk)) { matched.add(Interval.toInterval(start, end)); } } return matched; }
protected Collection<Interval<Integer>> match(List<? extends CoreMap> nodes, int start) { List<Interval<Integer>> matched = new ArrayList<Interval<Integer>>(); int minEnd = start + minNodes; int maxEnd = nodes.size(); if (maxNodes >= 0 && maxNodes + start < nodes.size()) { maxEnd = maxNodes + start; } for (int end = minEnd; end <= maxEnd; end++) { CoreMap chunk = ChunkAnnotationUtils.getMergedChunk(nodes, start, end, aggregators); if (nodePattern.match(chunk)) { matched.add(Interval.toInterval(start, end)); } } return matched; }
protected boolean extractAnnotation(List<? extends CoreMap> source, Map<Class, CoreMapAttributeAggregator> chunkAggregators) { annotation = ChunkAnnotationUtils.getMergedChunk(source, chunkOffsets.getBegin(), chunkOffsets.getEnd(), chunkAggregators); 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); text = annotation.get(CoreAnnotations.TextAnnotation.class); extractFunc.annotate(this, source.subList(chunkOffsets.getBegin(), chunkOffsets.getEnd())); return true; }
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; }
public CoreMap extractAnnotation(CoreMap sourceAnnotation) { if (chunkOffsets != null) { annotation = ChunkAnnotationUtils.getMergedChunk(sourceAnnotation.get(CoreAnnotations.NumerizedTokensAnnotation.class), chunkOffsets.getBegin(), chunkOffsets.getEnd(), CoreMapAttributeAggregator.DEFAULT_NUMERIC_TOKENS_AGGREGATORS ); if (sourceAnnotation.containsKey(CoreAnnotations.TextAnnotation.class)) { ChunkAnnotationUtils.annotateChunkText(annotation, sourceAnnotation); } charOffsets = Interval.toInterval(annotation.get(CoreAnnotations.CharacterOffsetBeginAnnotation.class), annotation.get(CoreAnnotations.CharacterOffsetEndAnnotation.class)); tokenOffsets = Interval.toInterval(annotation.get(CoreAnnotations.TokenBeginAnnotation.class), annotation.get(CoreAnnotations.TokenEndAnnotation.class), Interval.INTERVAL_OPEN_END); } else { Integer baseCharOffset = sourceAnnotation.get(CoreAnnotations.CharacterOffsetBeginAnnotation.class); if (baseCharOffset == null) { baseCharOffset = 0; }; chunkOffsets = ChunkAnnotationUtils.getChunkOffsetsUsingCharOffsets(sourceAnnotation.get(CoreAnnotations.NumerizedTokensAnnotation.class), charOffsets.getBegin() + baseCharOffset, charOffsets.getEnd() + baseCharOffset); CoreMap annotation2 = ChunkAnnotationUtils.getMergedChunk(sourceAnnotation.get(CoreAnnotations.NumerizedTokensAnnotation.class), chunkOffsets.getBegin(), chunkOffsets.getEnd(), CoreMapAttributeAggregator.DEFAULT_NUMERIC_TOKENS_AGGREGATORS ); annotation = ChunkAnnotationUtils.getAnnotatedChunkUsingCharOffsets(sourceAnnotation, charOffsets.getBegin(), charOffsets.getEnd()); tokenOffsets = Interval.toInterval(annotation.get(CoreAnnotations.TokenBeginAnnotation.class), annotation.get(CoreAnnotations.TokenEndAnnotation.class), Interval.INTERVAL_OPEN_END); annotation.set(CoreAnnotations.NumerizedTokensAnnotation.class, annotation2.get(CoreAnnotations.NumerizedTokensAnnotation.class)); } annotation.set(TimeExpression.ChildrenAnnotation.class, annotation.get(CoreAnnotations.NumerizedTokensAnnotation.class)); annotation.set(Annotation.class, this); text = annotation.get(CoreAnnotations.TextAnnotation.class); temporal = temporalFunc.apply(annotation); return annotation; }