:py:mod:`medkit.text.ner.date_attribute`
========================================

.. py:module:: medkit.text.ner.date_attribute


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

Classes
~~~~~~~

.. autoapisummary::

   medkit.text.ner.date_attribute.DateAttribute
   medkit.text.ner.date_attribute.DurationAttribute
   medkit.text.ner.date_attribute.RelativeDateDirection
   medkit.text.ner.date_attribute.RelativeDateAttribute




.. py:class:: DateAttribute(label: str, year: int | None = None, month: int | None = None, day: int | None = None, hour: int | None = None, minute: int | None = None, second: int | None = None, metadata: dict[str, Any] | None = None, uid: str | None = None)


   Bases: :py:obj:`medkit.core.Attribute`

   
   Attribute representing an absolute date or time associated to a segment or entity.

   The date or time can be incomplete: each date/time component is optional but
   at least one must be provided.













   :Attributes:

       **uid** : str
           Identifier of the attribute

       **label** : str
           Label of the attribute

       **value** : Any, optional
           String representation of the date with YYYY-MM-DD format for the date
           part and HH:MM:SS for the time part, if present. Missing components are
           replaced with question marks.

       **year** : int, optional
           Year component of the date

       **month** : int, optional
           Month component of the date

       **day** : int, optional
           Day component of the date

       **hour** : int, optional
           Hour component of the time

       **minute** : int, optional
           Minute component of the time

       **second** : int, optional
           Second component of the time

       **metadata** : dict of str to Any
           Metadata of the attribute


   ..
       !! processed by numpydoc !!
   .. py:attribute:: year
      :type: int | None

      

   .. py:attribute:: month
      :type: int | None

      

   .. py:attribute:: day
      :type: int | None

      

   .. py:attribute:: hour
      :type: int | None

      

   .. py:attribute:: minute
      :type: int | None

      

   .. py:attribute:: second
      :type: int | None

      

   .. py:method:: to_brat() -> str

      
      Return a value compatible with the brat format.
















      ..
          !! processed by numpydoc !!

   .. py:method:: to_spacy() -> str

      
      Return a value compatible with spaCy.
















      ..
          !! processed by numpydoc !!

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


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

      
      Create an Attribute from a dict.


      :Parameters:

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














      ..
          !! processed by numpydoc !!


.. py:class:: DurationAttribute(label: str, years: int = 0, months: int = 0, weeks: int = 0, days: int = 0, hours: int = 0, minutes: int = 0, seconds: int = 0, metadata: dict[str, Any] | None = None, uid: str | None = None)


   Bases: :py:obj:`medkit.core.Attribute`

   
   Attribute representing a time quantity associated to a segment or entity.

   Each date/time component is optional but at least one must be provided.













   :Attributes:

       **uid** : str
           Identifier of the attribute

       **label** : str
           Label of the attribute

       **value** : Any, optional
           String representation of the duration (ex: "1 year 10 months 2 days")

       **years** : int
           Year component of the date quantity

       **months** : int
           Month component of the date quantity

       **weeks** : int
           Week component of the date quantity

       **days** : int
           Day component of the date quantity

       **hours** : int
           Hour component of the time quantity

       **minutes** : int
           Minute component of the time quantity

       **seconds** : int
           Second component of the time quantity

       **metadata** : dict of str to Any
           Metadata of the attribute


   ..
       !! processed by numpydoc !!
   .. py:attribute:: years
      :type: int

      

   .. py:attribute:: months
      :type: int

      

   .. py:attribute:: weeks
      :type: int

      

   .. py:attribute:: days
      :type: int

      

   .. py:attribute:: hours
      :type: int

      

   .. py:attribute:: minutes
      :type: int

      

   .. py:attribute:: seconds
      :type: int

      

   .. py:method:: to_brat() -> str

      
      Return a value compatible with the brat format.
















      ..
          !! processed by numpydoc !!

   .. py:method:: to_spacy() -> str

      
      Return a value compatible with spaCy.
















      ..
          !! processed by numpydoc !!

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


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

      
      Create an Attribute from a dict.


      :Parameters:

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














      ..
          !! processed by numpydoc !!


.. py:class:: RelativeDateDirection(*args, **kwds)


   Bases: :py:obj:`enum.Enum`

   
   Direction of a :class:`~.RelativeDateAttribute`.
















   ..
       !! processed by numpydoc !!
   .. py:attribute:: PAST
      :value: 'past'

      

   .. py:attribute:: FUTURE
      :value: 'future'

      


.. py:class:: RelativeDateAttribute(label: str, direction: RelativeDateDirection, years: int = 0, months: int = 0, weeks: int = 0, days: int = 0, hours: int = 0, minutes: int = 0, seconds: int = 0, metadata: dict[str, Any] | None = None, uid: str | None = None)


   Bases: :py:obj:`medkit.core.Attribute`

   
   Attribute representing a relative date or time associated to a segment or entity.

   A date or time offset from an (unknown) reference date time with a direction.

   At least one date or time component must be non-zero.













   :Attributes:

       **uid** : str
           Identifier of the attribute

       **label** : str
           Label of the attribute

       **value** : Any, optional
           String representation of the relative date (ex: "+ 1 year 10 months 2
           days")

       **direction** : RelativeDateDirection
           Direction the relative date. Ex: "2 years ago" corresponds to the `PAST`
           direction and "in 2 weeks" to the `FUTURE` direction.

       **years** : int
           Year component of the date offset

       **months** : int
           Month component of the date offset

       **weeks** : int
           Week component of the date offset

       **days** : int
           Day component of the date offset

       **hours** : int
           Hour component of the time offset

       **minutes** : int
           Minute component of the time offset

       **seconds** : int
           Second component of the time offset

       **metadata** : dict of str to Any
           Metadata of the attribute


   ..
       !! processed by numpydoc !!
   .. py:attribute:: direction
      :type: RelativeDateDirection

      

   .. py:attribute:: years
      :type: int

      

   .. py:attribute:: months
      :type: int

      

   .. py:attribute:: weeks
      :type: int

      

   .. py:attribute:: days
      :type: int

      

   .. py:attribute:: hours
      :type: int

      

   .. py:attribute:: minutes
      :type: int

      

   .. py:attribute:: seconds
      :type: int

      

   .. py:method:: to_brat() -> str

      
      Return a value compatible with the brat format.
















      ..
          !! processed by numpydoc !!

   .. py:method:: to_spacy() -> str

      
      Return a value compatible with spaCy.
















      ..
          !! processed by numpydoc !!

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


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

      
      Create an Attribute from a dict.


      :Parameters:

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














      ..
          !! processed by numpydoc !!


