AnnoSpan¶
-
class
epitator.annospan.
AnnoSpan
(start, end, doc, label=None, metadata=None)[source]¶ Bases:
object
A span of text with an annotation applied to it.
-
adjacent_to
(other_span, max_dist=1)[source]¶ Return true if the span comes before or after other_span with at most max_dist charaters between them.
-
base_spans
¶
-
comes_before
(other_span, max_dist=1, allow_overlap=False)[source]¶ Return True if the span comes before the other_span and there are max_dist or fewer charaters between them.
>>> from .annotier import AnnoTier >>> from .annodoc import AnnoDoc >>> doc = AnnoDoc('one two three') >>> tier = AnnoTier([AnnoSpan(0, 3, doc), AnnoSpan(4, 7, doc)]) >>> tier.spans[0].comes_before(tier.spans[1]) True >>> tier.spans[1].comes_before(tier.spans[0]) False
-
distance
(other_span)[source]¶ The number of characters between this span and the other one. If the spans overlap the distance is the negative length of their overlap.
>>> from .annotier import AnnoTier >>> from .annodoc import AnnoDoc >>> doc = AnnoDoc('one two three') >>> tier = AnnoTier([AnnoSpan(0, 3, doc), AnnoSpan(8, 13, doc)]) >>> tier.spans[0].distance(tier.spans[1]) 5
-
doc
¶
-
end
¶
-
groupdict
()[source]¶ Return a dict with all the labeled matches.
>>> from .annodoc import AnnoDoc >>> doc = AnnoDoc('one two wolf') >>> number_span_g = SpanGroup([AnnoSpan(0, 3, doc, 'number'), ... AnnoSpan(4, 7, doc, 'number'), ... AnnoSpan(8, 12, doc, 'animal')]) >>> number_span_g.groupdict()['number'] [AnnoSpan(0-3, number), AnnoSpan(4-7, number)] >>> number_span_g.groupdict()['animal'] [AnnoSpan(8-12, animal)]
-
iterate_base_spans
()[source]¶ Recursively iterate over all base_spans including base_spans of child SpanGroups.
-
label
¶
-
metadata
¶
-
start
¶
-
text
¶
-
-
class
epitator.annospan.
SpanGroup
(base_spans, label=None, metadata=None)[source]¶ Bases:
epitator.annospan.AnnoSpan
A AnnoSpan that extends through a group of AnnoSpans.