medkit.text.postprocessing.attribute_duplicator#

Classes#

AttributeDuplicator

Annotator to copy attributes from a source segment to its nested segments.

Module Contents#

class medkit.text.postprocessing.attribute_duplicator.AttributeDuplicator(attr_labels: list[str], uid: str | None = None)#

Bases: medkit.core.Operation

Annotator to copy attributes from a source segment to its nested segments.

For each attribute to be duplicated, a new attribute is created in the nested segment.

Parameters:
attr_labelslist of str

Labels of the attributes to copy

uidstr, optional

Identifier of the annotator

attr_labels#
init_args#
run(source_segments: list[medkit.core.text.Segment], target_segments: list[medkit.core.text.Segment])#

Add attributes from source segments to all nested segments.

The nested segments are chosen among the target_segments based on their spans.

Parameters:
source_segmentslist of Segment

List of segments with attributes to copy

target_segmentslist of Segment

List of segments target

_duplicate_attr(attr: medkit.core.Attribute, target: medkit.core.text.Segment)#