medkit.core.text.annotation_container#

Classes:

TextAnnotationContainer(doc_id, raw_segment)

Manage a list of text annotations belonging to a text document.

class TextAnnotationContainer(doc_id, raw_segment)[source]#

Manage a list of text annotations belonging to a text document.

This behaves more or less like a list: calling len() and iterating are supported. Additional filtering is available through the get() method.

Also provides retrieval of entities, segments, relations, and handling of raw segment.

Attributes:

entities

Return the list of entities

relations

Return the list of relations

segments

Return the list of segments

Methods:

get_entities(*[, label, key])

Return a list of the entities of the document, optionally filtering by label or key.

get_relations(*[, label, key, source_id])

Return a list of the relations of the document, optionally filtering by label, key or source entity.

get_segments(*[, label, key])

Return a list of the segments of the document (not including entities), optionally filtering by label or key.

property segments: List[medkit.core.text.annotation.Segment]#

Return the list of segments

Return type

List[Segment]

property entities: List[medkit.core.text.annotation.Entity]#

Return the list of entities

Return type

List[Entity]

property relations: List[medkit.core.text.annotation.Relation]#

Return the list of relations

Return type

List[Relation]

get_segments(*, label=None, key=None)[source]#

Return a list of the segments of the document (not including entities), optionally filtering by label or key.

Parameters
  • label (Optional[str]) – Label to use to filter segments.

  • key (Optional[str]) – Key to use to filter segments.

Return type

List[Segment]

get_entities(*, label=None, key=None)[source]#

Return a list of the entities of the document, optionally filtering by label or key.

Parameters
  • label (Optional[str]) – Label to use to filter entities.

  • key (Optional[str]) – Key to use to filter entities.

Return type

List[Entity]

get_relations(*, label=None, key=None, source_id=None)[source]#

Return a list of the relations of the document, optionally filtering by label, key or source entity.

Parameters
  • label (Optional[str]) – Label to use to filter relations.

  • key (Optional[str]) – Key to use to filter relations.

  • source_id (Optional[str]) – Identifier of the source entity to use to filter relations.

Return type

List[Relation]