medkit.text.ner.date_attribute#
Classes#
Attribute representing an absolute date or time associated to a segment or entity. |
|
Attribute representing a time quantity associated to a segment or entity. |
|
Direction of a |
|
Attribute representing a relative date or time associated to a segment or entity. |
Module Contents#
- class medkit.text.ner.date_attribute.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:
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:
- uidstr
Identifier of the attribute
- labelstr
Label of the attribute
- valueAny, 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.
- yearint, optional
Year component of the date
- monthint, optional
Month component of the date
- dayint, optional
Day component of the date
- hourint, optional
Hour component of the time
- minuteint, optional
Minute component of the time
- secondint, optional
Second component of the time
- metadatadict of str to Any
Metadata of the attribute
- year: int | None#
- month: int | None#
- day: int | None#
- hour: int | None#
- minute: int | None#
- second: int | None#
- value#
- to_brat() str #
Return a value compatible with the brat format.
- to_spacy() str #
Return a value compatible with spaCy.
- to_dict() dict[str, Any] #
- classmethod from_dict(date_dict: dict[str, Any]) typing_extensions.Self #
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()
- class medkit.text.ner.date_attribute.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:
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:
- uidstr
Identifier of the attribute
- labelstr
Label of the attribute
- valueAny, optional
String representation of the duration (ex: “1 year 10 months 2 days”)
- yearsint
Year component of the date quantity
- monthsint
Month component of the date quantity
- weeksint
Week component of the date quantity
- daysint
Day component of the date quantity
- hoursint
Hour component of the time quantity
- minutesint
Minute component of the time quantity
- secondsint
Second component of the time quantity
- metadatadict of str to Any
Metadata of the attribute
- years: int#
- months: int#
- weeks: int#
- days: int#
- hours: int#
- minutes: int#
- seconds: int#
- value#
- to_brat() str #
Return a value compatible with the brat format.
- to_spacy() str #
Return a value compatible with spaCy.
- to_dict() dict[str, Any] #
- classmethod from_dict(duration_dict: dict[str, Any]) typing_extensions.Self #
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()
- class medkit.text.ner.date_attribute.RelativeDateDirection(*args, **kwds)#
Bases:
enum.Enum
Direction of a
RelativeDateAttribute
.- PAST = 'past'#
- FUTURE = 'future'#
- class medkit.text.ner.date_attribute.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:
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:
- uidstr
Identifier of the attribute
- labelstr
Label of the attribute
- valueAny, optional
String representation of the relative date (ex: “+ 1 year 10 months 2 days”)
- directionRelativeDateDirection
Direction the relative date. Ex: “2 years ago” corresponds to the PAST direction and “in 2 weeks” to the FUTURE direction.
- yearsint
Year component of the date offset
- monthsint
Month component of the date offset
- weeksint
Week component of the date offset
- daysint
Day component of the date offset
- hoursint
Hour component of the time offset
- minutesint
Minute component of the time offset
- secondsint
Second component of the time offset
- metadatadict of str to Any
Metadata of the attribute
- direction: RelativeDateDirection#
- years: int#
- months: int#
- weeks: int#
- days: int#
- hours: int#
- minutes: int#
- seconds: int#
- value#
- to_brat() str #
Return a value compatible with the brat format.
- to_spacy() str #
Return a value compatible with spaCy.
- to_dict() dict[str, Any] #
- classmethod from_dict(date_dict: dict[str, Any]) typing_extensions.Self #
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()