diff --git a/apis_core/apis_entities/rdfimport/E53_PlaceFromDNB.toml b/apis_core/apis_entities/rdfimport/E53_PlaceFromDNB.toml index c7dfdb5c0..9c62a62ff 100644 --- a/apis_core/apis_entities/rdfimport/E53_PlaceFromDNB.toml +++ b/apis_core/apis_entities/rdfimport/E53_PlaceFromDNB.toml @@ -1,7 +1,7 @@ ##################################################### # Create an E53_Place from a d-nb.info RDF endpoint # ##################################################### -superclass = "apis_core.apis_entities.abc.E53_Place" +superclass = "apis_core.apis_entities.abc.Place" # the second regex is for testing regex = "https://d-nb.info.*|/.*wien.rdf" [[attributes]] @@ -10,12 +10,11 @@ sparql = """ PREFIX gndo: SELECT ?label WHERE { - ?subject gndo:preferredNameForThePlaceOrGeographicName ?prefName - BIND(?prefName AS ?label) + ?subject gndo:preferredNameForThePlaceOrGeographicName ?label } """ [[attributes]] -# lon +# longitude sparql = ''' PREFIX geo: SELECT ?longitude @@ -26,7 +25,7 @@ WHERE { } ''' [[attributes]] -# lat +# latitude sparql = ''' PREFIX geo: SELECT ?latitude diff --git a/apis_core/apis_entities/rdfimport/E53_PlaceFromGeonames.toml b/apis_core/apis_entities/rdfimport/E53_PlaceFromGeonames.toml index 1cdeb5650..085a43c39 100644 --- a/apis_core/apis_entities/rdfimport/E53_PlaceFromGeonames.toml +++ b/apis_core/apis_entities/rdfimport/E53_PlaceFromGeonames.toml @@ -6,25 +6,22 @@ superclass = "apis_core.apis_entities.abc.E53_Place" regex = "https://sws.geonames.org.*|/.*achensee.rdf" [[attributes]] # name +#FILTER (LANGMATCHES(LANG(?prefName), "de") || LANGMATCHES(LANG(?prefName), "en") || LANG(?prefName) = "") sparql = """ PREFIX gn: -SELECT ?name +SELECT ?label WHERE { - ?subject gn:name|gn:officialName|gn:alternateName ?prefName - FILTER (LANGMATCHES(LANG(?prefName), "de") || LANGMATCHES(LANG(?prefName), "en") || LANG(?prefName) = "") - BIND(?prefName AS ?name) -} -ORDER BY ?lang -""" -[[attributes]] -# alternative_label -sparql = """ -PREFIX gn: -SELECT ?altName (LANG(?altName) AS ?lang) -WHERE { - ?subject gn:alternateName ?altName - FILTER (LANGMATCHES(LANG(?altName), "de") || LANGMATCHES(LANG(?altName), "en") || LANG(?prefName) = "") + OPTIONAL { + ?subject gn:name ?gnname . + } + OPTIONAL { + ?subject gn:officialName ?officialName + } + OPTIONAL { + ?subject gn:alternateName ?alternateName + } + BIND(COALESCE(?gnname, ?officialName, ?alternateName) AS ?label) } """ [[attributes]] @@ -40,20 +37,20 @@ WHERE { # lat sparql = """ PREFIX wgs84_pos: -SELECT ?lat +SELECT ?latitude WHERE { - ?subject wgs84_pos:lat ?lat. - ?subject wgs84_pos:long ?long + ?subject wgs84_pos:lat ?latitude. + ?subject wgs84_pos:long ?longitude } """ [[attributes]] # long sparql = """ PREFIX wgs84_pos: -SELECT ?long +SELECT ?longitude WHERE { - ?subject wgs84_pos:lat ?lat. - ?subject wgs84_pos:long ?long + ?subject wgs84_pos:lat ?latitude. + ?subject wgs84_pos:long ?longitude } """ [[attributes]] diff --git a/apis_core/apis_entities/rdfimport/E53_PlaceFromWikidata.toml b/apis_core/apis_entities/rdfimport/E53_PlaceFromWikidata.toml new file mode 100644 index 000000000..7bc2fbc8f --- /dev/null +++ b/apis_core/apis_entities/rdfimport/E53_PlaceFromWikidata.toml @@ -0,0 +1,38 @@ +#################################################### +# Create an E53_Place from a wikidata RDF endpoint # +#################################################### +superclass = "apis_core.apis_entities.abc.E53_Place" +regex = "http://www.wikidata.org.*" +[[attributes]] +# name +sparql = """ +PREFIX wdt: +PREFIX schema: +SELECT ?label +WHERE { + ?something schema:about ?subject . + ?subject rdfs:label ?label . + OPTIONAL { ?subject wdt:P1448/rdfs:label ?official_label } + BIND(COALESCE(?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) + } +'''