Skip to content

Commit

Permalink
GH-209: map datetime / temporal
Browse files Browse the repository at this point in the history
  • Loading branch information
barthanssens committed Jul 19, 2024
1 parent 4a61ef6 commit 31519f5
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# extra queries to be executed and data to be loaded
hda/sparql-fix-temporal.qry
sparql-delete-label-empty.qry
data-frequency.ttl
sparql-map-frequency.qry
hda/sparql-theme.qry
hda/sparql-fix-datetime.qry
hda/sparql-fix-dateformat.qry
sparql-date-type.qry
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Fix dateformat (EU date notation to ISO)

PREFIX dcat: <http://www.w3.org/ns/dcat#>
PREFIX dcterms: <http://purl.org/dc/terms/>

DELETE
{ ?s ?prop ?date }
INSERT
{ ?s ?prop ?iso }
WHERE
{ ?s ?prop ?date .
VALUES ?prop { dcterms:modified dcat:startDate dcat:endDate }
FILTER (REGEX(?date, "^(\\d{1,2})[/-](\\d{1,2})[/-](\\d{4})$"))
BIND (REPLACE(?date, "^(\\d{1,2})[/-](\\d{1,2})[/-](\\d{4})$", "$3-$2-$1") as ?iso)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Remove non-date expressions in modified

PREFIX dcat: <http://www.w3.org/ns/dcat#>
PREFIX dcterms: <http://purl.org/dc/terms/>

DELETE
{ ?s ?prop ?label }
WHERE
{ ?s ?prop ?label .
VALUES ?prop { dcterms:modified dcat:startDate dcat:endDate }
FILTER (REGEX(?label, "^\\D+"))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Split temporal into startdate / enddate

PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX dcat: <http://www.w3.org/ns/dcat#>

DELETE
{ ?s dcterms:temporal ?temp }
INSERT
{ ?s dcterms:temporal [
dcat:startDate ?start ;
dcat:endDate ?end ]
}
WHERE
{ ?s dcterms:temporal ?temp .
FILTER (REGEX(?temp, "^\\S+ - \\S+"))
BIND (
REPLACE(
STRBEFORE(?temp, " - "), "-\\D+$", "")
as ?start)
BIND (
REPLACE(
STRAFTER(?temp, " - "), " - \\?$", "")
as ?end)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Set category / theme

PREFIX dcat: <http://www.w3.org/ns/dcat#>
PREFIX dgov: <http://data.gov.be#>

DELETE
{ ?dataset dcat:theme "HEAL" }
INSERT
{ ?dataset dcat:theme <http://publications.europa.eu/resource/authority/data-theme/HEAL> .
?dataset dgov:theme <http://data.gov.be/en/taxonomy/term/40> .
}
WHERE
{ ?dataset dcat:theme "HEAL" }
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ WHERE {
dcterms:modified
} .
BIND(
STRDT(STR(?o), IF(STRLEN(STR(?o)) = 10, xsd:date, xsd:dateTime))
AS ?dtype
STRDT(STR(?o),
IF(STRLEN(STR(?o)) = 4, xsd:gYear,
IF(STRLEN(STR(?o)) = 10, xsd:date,
xsd:dateTime)
)
) AS ?dtype
)
FILTER ( datatype(?o) = xsd:string )
}

0 comments on commit 31519f5

Please sign in to comment.