-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(apis_entities): import improvements for E53_Place imports
- Loading branch information
Showing
3 changed files
with
60 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
apis_core/apis_entities/rdfimport/E53_PlaceFromWikidata.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: <http://www.wikidata.org/prop/direct/> | ||
PREFIX schema: <http://schema.org/> | ||
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: <http://www.wikidata.org/prop/direct/> | ||
SELECT ?longitude | ||
WHERE { | ||
?subject wdt:P625 ?geo1 . | ||
BIND(REPLACE(str(?geo1), "Point\\((\\d+\\.\\d+).*$", "$1") as ?longitude) | ||
} | ||
''' | ||
[[attributes]] | ||
# latitude | ||
sparql = ''' | ||
PREFIX wdt: <http://www.wikidata.org/prop/direct/> | ||
SELECT ?latitude | ||
WHERE { | ||
?subject wdt:P625 ?geo1 . | ||
BIND(REPLACE(str(?geo1), "Point\\((\\d+\\.\\d+) (\\d+\\.\\d+).*$", "$2") as ?latitude) | ||
} | ||
''' |