gatenlp.impl.sortedintvls module — GATE NLP library (gatenlp) documentation

# 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`

  Bases: `object`

  `add`(start, end, data)
  `at`(start, end)

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

  `covering`(start, end)

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

  `discard`(start, end, data)
  `ending_after`(offset)

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

  `ending_at`(offset)

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

  `ending_to`(offset)

    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`()

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

  `irange`(minoff=None, maxoff=None, reverse=False)
  `lasts`()

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

  `max_end`()

    Returns the biggest end offset we have :return:

  `min_start`()

    Returns the smallest start offset we have :return:

  `overlapping`(start, end)

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

  `remove`(start, end, data)
  `starting_at`(offset)

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

  `starting_before`(offset)

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

  `starting_from`(offset)

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

  `update`(tupleiterable)
  `within`(start, end)

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