:py:mod:`medkit.core.text.annotation`
=====================================

.. py:module:: medkit.core.text.annotation


Module Contents
---------------

Classes
~~~~~~~

.. autoapisummary::

   medkit.core.text.annotation.TextAnnotation
   medkit.core.text.annotation.Segment
   medkit.core.text.annotation.Entity
   medkit.core.text.annotation.Relation




.. py:class:: TextAnnotation(label: str, attrs: list[medkit.core.attribute.Attribute] | None = None, metadata: dict[str, Any] | None = None, uid: str | None = None, attr_container_class: type[medkit.core.attribute_container.AttributeContainer] = AttributeContainer)


   Bases: :py:obj:`abc.ABC`, :py:obj:`medkit.core.dict_conv.SubclassMapping`

   
   Base abstract class for all text annotations.














   :Attributes:

       **uid** : str
           Unique identifier of the annotation.

       **label** : str
           The label for this annotation (e.g., SENTENCE)

       **attrs** : AttributeContainer
           Attributes of the annotation. Stored in a
           :class:{~medkit.core.AttributeContainer} but can be passed as a list at
           init.

       **metadata** : dict of str to Any
           The metadata of the annotation

       **keys** : set of str
           Pipeline output keys to which the annotation belongs to.


   ..
       !! processed by numpydoc !!
   .. py:attribute:: uid
      :type: str

      

   .. py:attribute:: label
      :type: str

      

   .. py:attribute:: attrs
      :type: medkit.core.attribute_container.AttributeContainer

      

   .. py:attribute:: metadata
      :type: dict[str, Any]

      

   .. py:attribute:: keys
      :type: set[str]

      

   .. py:method:: __init_subclass__()
      :classmethod:


   .. py:method:: from_dict(ann_dict: dict[str, Any]) -> typing_extensions.Self
      :classmethod:


   .. py:method:: to_dict() -> dict[str, Any]
      :abstractmethod:



.. py:class:: Segment(label: str, text: str, spans: list[medkit.core.text.span.AnySpan], attrs: list[medkit.core.attribute.Attribute] | None = None, metadata: dict[str, Any] | None = None, uid: str | None = None, store: medkit.core.store.Store | None = None, attr_container_class: type[medkit.core.attribute_container.AttributeContainer] = AttributeContainer)


   Bases: :py:obj:`TextAnnotation`

   
   Text segment referencing part of an :class:`~medkit.core.text.TextDocument`.














   :Attributes:

       **uid** : str
           The segment identifier.

       **label** : str
           The label for this segment (e.g., SENTENCE)

       **text** : str
           Text of the segment.

       **spans** : list of AnySpan
           List of spans indicating which parts of the segment text correspond to
           which part of the document's full text.

       **attrs** : AttributeContainer
           Attributes of the segment. Stored in a
           :class:{~medkit.core.AttributeContainer} but can be passed as a list at
           init.

       **metadata** : dict of str to Any
           The metadata of the segment

       **keys** : set of str
           Pipeline output keys to which the segment belongs to.


   ..
       !! processed by numpydoc !!
   .. py:attribute:: spans
      :type: list[medkit.core.text.span.AnySpan]

      

   .. py:attribute:: text
      :type: str

      

   .. py:method:: to_dict() -> dict[str, Any]


   .. py:method:: from_dict(segment_dict: dict[str, Any]) -> typing_extensions.Self
      :classmethod:

      
      Create a Segment from a dict.


      :Parameters:

          **segment_dict** : dict of str to Any
              A dictionary from a serialized segment as generated by to_dict()














      ..
          !! processed by numpydoc !!


.. py:class:: Entity(label: str, text: str, spans: list[medkit.core.text.span.AnySpan], attrs: list[medkit.core.attribute.Attribute] | None = None, metadata: dict[str, Any] | None = None, uid: str | None = None, store: medkit.core.store.Store | None = None, attr_container_class: type[medkit.core.text.entity_attribute_container.EntityAttributeContainer] = EntityAttributeContainer)


   Bases: :py:obj:`Segment`

   
   Text entity referencing part of an :class:`~medkit.core.text.TextDocument`.














   :Attributes:

       **uid** : str
           The entity identifier.

       **label** : str
           The label for this entity (e.g., DISEASE)

       **text** : str
           Text of the entity.

       **spans** : list of AnySpan
           List of spans indicating which parts of the entity text correspond to
           which part of the document's full text.

       **attrs** : EntityAttributeContainer
           Attributes of the entity. Stored in a
           :class:{~medkit.core.EntityAttributeContainer} but can be passed as a list at
           init.

       **metadata** : dict of str to Any
           The metadata of the entity

       **keys** : set of str
           Pipeline output keys to which the entity belongs to.


   ..
       !! processed by numpydoc !!
   .. py:attribute:: attrs
      :type: medkit.core.text.entity_attribute_container.EntityAttributeContainer

      


.. py:class:: Relation(label: str, source_id: str, target_id: str, attrs: list[medkit.core.attribute.Attribute] | None = None, metadata: dict[str, Any] | None = None, uid: str | None = None, store: medkit.core.store.Store | None = None, attr_container_class: type[medkit.core.attribute_container.AttributeContainer] = AttributeContainer)


   Bases: :py:obj:`TextAnnotation`

   
   Relation between two text entities.














   :Attributes:

       **uid** : str
           The identifier of the relation

       **label** : str
           The relation label

       **source_id** : str
           The identifier of the entity from which the relation is defined

       **target_id** : str
           The identifier of the entity to which the relation is defined

       **attrs** : AttributeContainer
           The attributes of the relation

       **metadata** : dict of str to Any
           The metadata of the relation

       **keys** : set of str
           Pipeline output keys to which the relation belongs to


   ..
       !! processed by numpydoc !!
   .. py:attribute:: source_id
      :type: str

      

   .. py:attribute:: target_id
      :type: str

      

   .. py:method:: to_dict() -> dict[str, Any]


   .. py:method:: from_dict(relation_dict: dict[str, Any]) -> typing_extensions.Self
      :classmethod:

      
      Create a Relation from a dict.


      :Parameters:

          **relation_dict** : dict of str to Any
              A dictionary from a serialized relation as generated by to_dict()














      ..
          !! processed by numpydoc !!


