ontocast.tool.facts_validation.date_values¶
Date values for nodes that stand for a date, read from their labels.
A node standing for a date (an instant, a day, a month, a year) must say which
date it is with a typed ISO 8601 literal: a label alone is text no query can
compare or order. The render is told so; this pass makes it hold in code. A
node is taken to stand for a date when it is the object of a temporal property,
is typed with an OWL-Time class, or carries a label that is a whole calendar
date or month. When its label parses as a date and it carries no date-typed
literal, the parsed value is added: through the one catalog property whose
domain fits the node and whose range is the value's datatype, else OWL-Time's
inXSD* property for a time:Instant, else rdf:value. Nothing is
removed, and a label that does not parse is left as it is. Month names are
read in English.
Attributes¶
DATE_DATATYPES = CALENDAR_DATATYPES
module-attribute
¶
__all__ = ['DATE_DATATYPES', 'add_date_values', 'parse_date_label']
module-attribute
¶
Classes¶
Functions:¶
add_date_values(graph, ontology_graph, fact_namespaces)
¶
Give every undated node that stands for a date the value its label names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
RDFGraph
|
The aggregated facts graph; edited in place. |
required |
ontology_graph
|
RDFGraph
|
The ontology context the facts were validated against. |
required |
fact_namespaces
|
Sequence[str]
|
Namespaces holding minted instances. |
required |
Returns:
| Type | Description |
|---|---|
list[GraphRepairRecord]
|
list[GraphRepairRecord]: One |
list[GraphRepairRecord]
|
target the added literal. |
Source code in ontocast/tool/facts_validation/date_values.py
parse_date_label(label, *, allow_year)
¶
The typed ISO 8601 literal a label names as a whole, or None.
Reads ISO forms (2021, 2021-06, 2021-06-27, a date-time) and
English calendar forms (June 2021, 27 June 2021, June 27, 2021,
abbreviated months too). The whole label must be the date: mid-June
2021 or summer 2021 name no single value and give None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The node's label. |
required |
allow_year
|
bool
|
Whether a bare four-digit year counts; it is a date only where the node's position already says it stands for a time. |
required |
Returns:
| Type | Description |
|---|---|
Literal | None
|
Literal | None: An |
Literal | None
|
|