public static double getMidPoint(Interval<Integer> interval) { return (interval.getBegin() + interval.getEnd())/2.0; }
public static double getRadius(Interval<Integer> interval) { return (interval.getEnd() - interval.getBegin())/2.0; }
public static <T> List<T> mergeListWithSortedMatchedPreAggregated(List<? extends T> list, List<? extends T> matched, Function<T, Interval<Integer>> toIntervalFunc) { List<T> merged = new ArrayList<>(list.size()); // Approximate size int last = 0; for (T m : matched) { Interval<Integer> interval = toIntervalFunc.apply(m); int start = interval.getBegin(); int end = interval.getEnd(); if (start >= last) { merged.addAll(list.subList(last, start)); merged.add(m); last = end; } } // Add rest of elements if (last < list.size()) { merged.addAll(list.subList(last, list.size())); } return merged; }
public static <T> List<T> mergeListWithSortedMatched(List<? extends T> list, List<? extends HasInterval<Integer>> matched, Function<List<? extends T>, T> aggregator) { List<T> merged = new ArrayList<>(list.size()); // Approximate size int last = 0; for (HasInterval<Integer> m : matched) { Interval<Integer> interval = m.getInterval(); int start = interval.getBegin(); int end = interval.getEnd(); if (start >= last) { merged.addAll(list.subList(last, start)); T t = aggregator.apply(list.subList(start, end)); merged.add(t); last = end; } } // Add rest of elements if (last < list.size()) { merged.addAll(list.subList(last, list.size())); } return merged; }
for (T item:items) { Interval<E> itemInterval = toIntervalFunc.apply(item); E mBegin = itemInterval.getBegin(); E mEnd = itemInterval.getEnd(); PartialScoredList<T,E> bestk = bestNonOverlapping.get(mEnd);
res.alignments[p] = Interval.toInterval(res.matched.size()-1, res.matched.size()); } else { res.alignments[p] = Interval.toInterval(res.alignments[p].getBegin(), res.alignments[p].getEnd() + 1);
public boolean contains(Interval<E> other) { boolean containsOtherBegin = (other.includesBegin())? contains(other.getBegin()): containsOpen(other.getBegin()); boolean containsOtherEnd = (other.includesEnd())? contains(other.getEnd()): containsOpen(other.getEnd()); return (containsOtherBegin && containsOtherEnd); }
protected boolean extractAnnotation(List<? extends CoreMap> source, CoreMapAggregator aggregator) { annotation = aggregator.merge(source, chunkOffsets.getBegin(), chunkOffsets.getEnd()); 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; }
if (chunkOffsets != null) { annotation = aggregator.merge((List<? extends CoreMap>) sourceAnnotation.get(tokensAnnotationKey), chunkOffsets.getBegin(), chunkOffsets.getEnd()); if (sourceAnnotation.containsKey(CoreAnnotations.TextAnnotation.class)) { ChunkAnnotationUtils.annotateChunkText(annotation, sourceAnnotation); annotation.set(CoreAnnotations.TokenBeginAnnotation.class, tokenOffsets.getBegin()); charOffsets.getBegin() + baseCharOffset, charOffsets.getEnd() + baseCharOffset); CoreMap annotation2 = aggregator.merge((List<? extends CoreMap>) sourceAnnotation.get(tokensAnnotationKey), chunkOffsets.getBegin(), chunkOffsets.getEnd()); 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);
public static double getRadius(Interval<Integer> interval) { return (interval.getEnd() - interval.getBegin())/2.0; }
public static double getMidPoint(Interval<Integer> interval) { return (interval.getBegin() + interval.getEnd())/2.0; }
@Override public Double apply(HasInterval<Integer> in) { Interval<Integer> interval = in.getInterval(); return (double) (interval.getEnd() - interval.getBegin()); } };
public boolean contains(Interval<E> other) { boolean containsOtherBegin = (other.includesBegin())? contains(other.getBegin()): containsOpen(other.getBegin()); boolean containsOtherEnd = (other.includesEnd())? contains(other.getEnd()): containsOpen(other.getEnd()); return (containsOtherBegin && containsOtherEnd); }
public boolean contains(Interval<E> other) { boolean containsOtherBegin = (other.includesBegin())? contains(other.getBegin()): containsOpen(other.getBegin()); boolean containsOtherEnd = (other.includesEnd())? contains(other.getEnd()): containsOpen(other.getEnd()); return (containsOtherBegin && containsOtherEnd); }
public boolean contains(Interval<E> other) { boolean containsOtherBegin = (other.includesBegin())? contains(other.getBegin()): containsOpen(other.getBegin()); boolean containsOtherEnd = (other.includesEnd())? contains(other.getEnd()): containsOpen(other.getEnd()); return (containsOtherBegin && containsOtherEnd); }
protected boolean extractAnnotation(List<? extends CoreMap> source, CoreMapAggregator aggregator) { annotation = aggregator.merge(source, chunkOffsets.getBegin(), chunkOffsets.getEnd()); 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; }
protected boolean extractAnnotation(List<? extends CoreMap> source, CoreMapAggregator aggregator) { annotation = aggregator.merge(source, chunkOffsets.getBegin(), chunkOffsets.getEnd()); 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; }
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; }