dates ¶
Explicit calendar date extraction from English text.
DateMention dataclass ¶
A calendar date with a source span and known date components.
Attributes:
| Name | Type | Description |
|---|---|---|
text | str | Matched date text. |
start | int | Zero-based character offset. |
end | int | Exclusive end offset. |
resolution | int | 1 for year, 2 for month/year, 3 for full date, 4 for month/day. |
month | int | Month number, or zero when absent. |
day | int | Day number, or zero when absent. |
year | int | Year, or zero when absent. |
DateIssue dataclass ¶
An ambiguous or invalid date candidate with its text, offset, and reason.
DateResult dataclass ¶
Date mentions and rejected candidates for an input body.
Attributes:
| Name | Type | Description |
|---|---|---|
text | str | Analyzed body. |
mentions | tuple[DateMention, ...] | Accepted dates in source order. |
issues | tuple[DateIssue, ...] | Ambiguous or invalid candidates in source order. |
analyze_dates ¶
Extract calendar dates and years from 1500 through 2199.
Missing components stay zero. Ambiguous numeric dates are reported as issues unless numeric_order resolves them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text | str | Prepared English body. | required |
numeric_order | NumericDateOrder | None |
| None |
Returns:
| Type | Description |
|---|---|
DateResult | Accepted date mentions and diagnostics with source character offsets. |
Raises:
| Type | Description |
|---|---|
TypeError | If |
ValueError | If |