medkit.core.text.span#

Classes#

AnySpan

Helper class that provides a standard way to create an ABC using

Span

Slice of text extracted from the original text.

ModifiedSpan

Slice of text not present in the original text.

Module Contents#

class medkit.core.text.span.AnySpan#

Bases: abc.ABC, medkit.core.dict_conv.SubclassMapping

Helper class that provides a standard way to create an ABC using inheritance.

length: int#
classmethod __init_subclass__()#
classmethod from_dict(ann_dict: dict[str, Any]) typing_extensions.Self#
abstract to_dict() dict[str, Any]#
class medkit.core.text.span.Span#

Bases: AnySpan

Slice of text extracted from the original text.

Parameters:
startint

Index of the first character in the original text

endint

Index of the last character in the original text, plus one

start: int#
end: int#
property length#
to_dict() dict[str, Any]#
overlaps(other: Span)#

Test if 2 spans reference at least one character in common.

classmethod from_dict(span_dict: dict[str, Any]) typing_extensions.Self#

Create a Span from a dict.

Parameters:
span_dict: dict

A dictionary from a serialized span as generated by to_dict()

class medkit.core.text.span.ModifiedSpan#

Bases: AnySpan

Slice of text not present in the original text.

Parameters:
lengthint

Number of characters

replaced_spanslist of Span

Slices of the original text that this span is replacing

length: int#
replaced_spans: list[Span]#
to_dict() dict[str, Any]#
classmethod from_dict(modified_span_dict: dict[str, Any]) typing_extensions.Self#

Create a Modified from a dict.

Parameters:
modified_span_dictdict of str to Any

A dictionary from a serialized ModifiedSpan as generated by to_dict()