From 918c45ce53fd209e86a5393ea63acf38fbe71d90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Schl=C3=B6gl?= Date: Fri, 13 Dec 2024 09:43:52 +0100 Subject: [PATCH] fix: add more sameAs --- apis_ontology/rdfimport/EventFromDNB.toml | 10 ++++ .../rdfimport/InstitutionFromWikidata.toml | 10 ++++ .../rdfimport/PersonFromWikidata.toml | 22 +++++++ .../rdfimport/PlaceFromWikidata.toml | 57 +++++++++++++++++++ 4 files changed, 99 insertions(+) create mode 100644 apis_ontology/rdfimport/PlaceFromWikidata.toml diff --git a/apis_ontology/rdfimport/EventFromDNB.toml b/apis_ontology/rdfimport/EventFromDNB.toml index a64fd98..616fe7a 100644 --- a/apis_ontology/rdfimport/EventFromDNB.toml +++ b/apis_ontology/rdfimport/EventFromDNB.toml @@ -53,3 +53,13 @@ WHERE { gndo:place ?relatedPlace__Place__FandStattIn . } """ +[[attributes]] +# sameAs +sparql = ''' +PREFIX owl: +SELECT (GROUP_CONCAT(?sameas_pre; separator='|') as ?sameas) +WHERE { + ?subject owl:sameAs ?sameas_pre +} +GROUP BY ?subject +''' diff --git a/apis_ontology/rdfimport/InstitutionFromWikidata.toml b/apis_ontology/rdfimport/InstitutionFromWikidata.toml index 840522e..faaa0fb 100644 --- a/apis_ontology/rdfimport/InstitutionFromWikidata.toml +++ b/apis_ontology/rdfimport/InstitutionFromWikidata.toml @@ -24,3 +24,13 @@ WHERE { BIND(COALESCE(?label_de, ?label_en, ?label) AS ?name) } """ +[[attributes]] +# sameAs +sparql = ''' +PREFIX owl: +SELECT (GROUP_CONCAT(?sameas_pre; separator='|') as ?sameas) +WHERE { + ?subject wdtn:P227|wdtn:P1566|wdtn:P214|wdtn:P244 ?sameas_pre +} +GROUP BY ?subject +''' diff --git a/apis_ontology/rdfimport/PersonFromWikidata.toml b/apis_ontology/rdfimport/PersonFromWikidata.toml index b3de5ac..a6b049d 100644 --- a/apis_ontology/rdfimport/PersonFromWikidata.toml +++ b/apis_ontology/rdfimport/PersonFromWikidata.toml @@ -4,6 +4,18 @@ ############################################## superclass = "apis_ontology.models.Person" regex = "http://www.wikidata.org.*" +sameas = """ +PREFIX wdtn: +PREFIX wdt: +SELECT ?sameas ?parl_url +WHERE { +?subject wdtn:P227 ?sameas +OPTIONAL { +?subject wdt:P2280 ?parl_nr . +BIND(concat("https://www.parlament.gv.at/WWER/PAD_", str(?parl_nr)) AS ?parl_url) +} +} +""" [[attributes]] # name sparql = """ @@ -50,3 +62,13 @@ WHERE { BIND(CONCAT(STR(YEAR(?death)),"-",STR(MONTH(?death)),"-",STR(DAY(?death))) AS ?end_date_written) } """ +[[attributes]] +# sameAs +sparql = ''' +PREFIX owl: +SELECT (GROUP_CONCAT(?sameas_pre; separator='|') as ?sameas) +WHERE { + ?subject wdtn:P227|wdtn:P1566|wdtn:P214|wdtn:P244 ?sameas_pre +} +GROUP BY ?subject +''' diff --git a/apis_ontology/rdfimport/PlaceFromWikidata.toml b/apis_ontology/rdfimport/PlaceFromWikidata.toml new file mode 100644 index 0000000..8ca5392 --- /dev/null +++ b/apis_ontology/rdfimport/PlaceFromWikidata.toml @@ -0,0 +1,57 @@ + +#################################################### +# Create an E53_Place from a wikidata RDF endpoint # +#################################################### +superclass = "apis_ontology.models.Place" +regex = "http://www.wikidata.org.*" +[[attributes]] +# label +sparql = """ +PREFIX wdt: +PREFIX schema: +SELECT ?label +WHERE { + ?something schema:about ?subject . + ?subject rdfs:label ?label . + OPTIONAL { ?subject wdt:P1448/rdfs:label ?official_label } + OPTIONAL{ + ?subject rdfs:label ?label_de . + FILTER(lang(?label_de) = "de") + } + OPTIONAL{ + ?subject rdfs:label ?label_en . + FILTER(lang(?label_en) = "en") + } + BIND(COALESCE(?label_de, ?label_en, ?official_label, ?label) AS ?label) +} +""" +[[attributes]] +# longitude +sparql = ''' +PREFIX wdt: +SELECT ?longitude +WHERE { + ?subject wdt:P625 ?geo1 . + BIND(REPLACE(str(?geo1), "Point\\((\\d+\\.\\d+).*$", "$1") as ?longitude) + } +''' +[[attributes]] +# latitude +sparql = ''' +PREFIX wdt: +SELECT ?latitude +WHERE { + ?subject wdt:P625 ?geo1 . + BIND(REPLACE(str(?geo1), "Point\\((\\d+\\.\\d+) (\\d+\\.\\d+).*$", "$2") as ?latitude) + } +''' +[[attributes]] +# sameAs +sparql = ''' +PREFIX owl: +SELECT (GROUP_CONCAT(?sameas_pre; separator='|') as ?sameas) +WHERE { + ?subject wdtn:P227|wdtn:P1566|wdtn:P214|wdtn:P244 ?sameas_pre +} +GROUP BY ?subject +'''