Skip to content

edsnlp.pipes.misc.dates.models

BaseDate [source]

Bases: BaseModel

remove_space [source]

Remove spaces. Useful for coping with ill-formatted PDF extractions.

AbsoluteDate [source]

Bases: BaseDate

to_datetime [source]

Convert the date to a datetime.datetime object.

Parameters

PARAMETER DESCRIPTION
tz

The timezone to use. Defaults to None.

TYPE: Optional[Union[str, timezone]] DEFAULT: None

note_datetime

The datetime of the note. Used to infer missing parts of the date.

TYPE: Optional[Union[datetime, datetime]] DEFAULT: None

infer_from_context

Whether to infer missing parts of the date from the note datetime. In a (year, month, day) triplet:

- if only year is missing, it will be inferred from the note datetime
- if only month is missing, it will be inferred from the note datetime
- if only day is missing, it will be set to `default_day`
- if only the year is given, the day and month will be set to
  `default_day` and `default_month`
- if only the month is given, the day will be set to `default_day`
  and the year will be inferred from the note datetime
- if only the day is given, the month and year will be inferred from
  the note datetime

TYPE: bool DEFAULT: None

default_day

Default day to use when inferring missing parts of the date.

TYPE: int DEFAULT: 1

default_month

Default month to use when inferring missing parts of the date.

TYPE: int DEFAULT: 1

RETURNS DESCRIPTION
Union[datetime, None]

Relative [source]

Bases: BaseDate

parse_unit

Units need to be handled separately.

This validator modifies the key corresponding to the unit with the detected value

Parameters

PARAMETER DESCRIPTION
d

Original data

TYPE: Dict[str, str]

RETURNS DESCRIPTION
Dict[str, str]

Transformed data

RelativeDate [source]

Bases: Relative

handle_specifics

Specific patterns such as aujourd'hui, hier, etc, need to be handled separately.

Parameters

PARAMETER DESCRIPTION
d

Original data.

TYPE: Dict[str, str]

RETURNS DESCRIPTION
Dict[str, str]

Modified data.