gatenlp.impl.sortedintvls module

A simple class that represents a collection of sorted intervals and allows for some basic interval-based operations. Internally this stores the intervals using standard sorted lists. This is not optimal and my incur a O(n) overhead on some operations depending on the result set. It also may incur a significant overhead for creating and maintaning the sorted lists. NOTE: this stores a tuple (start, end, object) in the sorted list and uses a key function that returns the offset for sorting.

class gatenlp.impl.sortedintvls.SortedIntvls[source]

Bases: object

add(start, end, data)[source]
at(start, end)[source]

Return iterable of tuples where start==start and end==end :param start: :param end: :return:

covering(start, end)[source]

Intervals that contain the given range :param start: :param end: :return:

discard(start, end, data)[source]
ending_after(offset)[source]

Intervals the end after the given offset NOTE: the result is sorted by end offset! :param offset: :return:

ending_at(offset)[source]

Return an iterable of (start, end, data) tuples where end==offset :param offset: the ending offset :return:

ending_to(offset)[source]

Intervals that end before or at the given end offset. NOTE: the result is sorted by end offset, not start offset! :param offset: :return:

firsts()[source]

Return an iterator of all intervals at the minimum start offset that exists. :return:

irange(minoff=None, maxoff=None, reverse=False)[source]
lasts()[source]

Return an iterator of all intervals at the maximum start offset that exists. :return:

max_end()[source]

Returns the biggest end offset we have :return:

min_start()[source]

Returns the smallest start offset we have :return:

overlapping(start, end)[source]

Intervals that overlap with the given range. :param start: :param end: :return:

remove(start, end, data)[source]
starting_at(offset)[source]

Return an iterable of (start, end, data) tuples where start==offset :param offset: the starting offset :return:

starting_before(offset)[source]

Intervals that start before offset :param offset: :return:

starting_from(offset)[source]

Intervals that start at or after offset. :param offset: :return:

update(tupleiterable)[source]
within(start, end)[source]

Return intervals which are fully contained within start…end :param start: :param end: :return: