gatenlp.annotation module — GATE NLP library (gatenlp) documentation

# gatenlp.annotation module

An annotation is immutable, but the features it contains are mutable.

class `gatenlp.annotation.` `Annotation`(start: int, end: int, annot_type: str, annid: int = 0, features=None)

  Bases: `gatenlp.feature_bearer.FeatureBearer`

  An annotation represents information about a span of text. It contains the start and end offsets of the span, an “annotation type” and it is a feature bearer. In addition it contains an id which has no meaning for the annotation itself but is used to uniquely identify an annotation within the set it is contained in. All fields except the features are immutable, once the annotation has been created only the features can be changed.

  Create a new annotation instance. NOTE: this should almost never be done directly and instead the method annotation_set.add should be used! Once an annotation has been created, the start, end, type and id fields must not be changed! :param start: start offset of the annotation :param end: end offset of the annotation :param annot_type: annotation type :param annot_id: the id of the annotation :param owner_set: the containing annotation set :param features: an initial collection of features, None for no features.

  property `end`
  property `features`
  static `from_dict`(dictrepr, owner_set=None, **kwargs)
  property `gatenlp_type`
  property `id`
  `is_coextensive`(start: int, end: int) → bool

    Checks if this annotation is coextensive with the given span, annotation or annotation set, i.e. has exactly the same start and end offsets.

    Parameters

      - start – start offset of the span

      - end – end offset of the span

    Returns

      True if coextensive, False otherwise

  `is_covering`(start: int, end: int) → bool

    Checks if this annotation is covering the given span, annotation or annotation set, i.e. both the given start and end offsets are after the start of this annotation and before the end of this annotation.

    Parameters

      - start – start offset of the span

      - end – end offset of the span

    Returns

      True if within, False otherwise

  `is_inside`(offset: int) → bool

    Check if the given offset falls somewhere inside the span of this annotation. :param offset: the offset to check :return: True if the offset is inside the span of this annotation

  `is_overlapping`(start: int, end: int) → bool

    Checks if this annotation is overlapping with the given span, annotation or annotation set. An annotation is overlapping with a span if the first or last character is inside that span.

    Parameters

      - start – start offset of the span

      - end – end offset of the span

    Returns

      True if overlapping, False otherwise

  `is_within`(start: int, end: int) → bool

    Checks if this annotation is within the given span, annotation or annotation set, i.e. both the start and end offsets of this annotation are after the given start and before the given end.

    Parameters

      - start – start offset of the span

      - end – end offset of the span

    Returns

      True if within, False otherwise

  property `start`
  `to_dict`(offset_mapper=None, offset_type=None)
  property `type`