-
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.
refactor: replace yaml with toml for rdf parser
- Loading branch information
Showing
3 changed files
with
247 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,244 @@ | ||
######################################### | ||
# Create an entity `apis_ontology.Place` | ||
# from a geonames RDF endpoint | ||
########################################## | ||
[PlaceFromGeonames] | ||
model = "apis_ontology.Place" | ||
filter_sparql = """ | ||
PREFIX gn: <http://www.geonames.org/ontology#> | ||
ASK { | ||
?subject gn:featureClass <https://www.geonames.org/ontology#P> . | ||
?subject gn:featureCode <https://www.geonames.org/ontology#P.PPL> . | ||
} | ||
""" | ||
[[PlaceFromGeonames.attributes]] | ||
# name | ||
sparql = """ | ||
PREFIX gn: <http://www.geonames.org/ontology#> | ||
SELECT ?name | ||
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 | ||
""" | ||
[[PlaceFromGeonames.attributes]] | ||
# alternative_label | ||
sparql = """ | ||
PREFIX gn: <http://www.geonames.org/ontology#> | ||
SELECT ?altName (LANG(?altName) AS ?lang) | ||
WHERE { | ||
?subject gn:alternateName ?altName | ||
FILTER (LANGMATCHES(LANG(?altName), "de") || LANGMATCHES(LANG(?altName), "en") || LANG(?prefName) = "") | ||
} | ||
""" | ||
[[PlaceFromGeonames.attributes]] | ||
# kind | ||
sparql = """ | ||
PREFIX gn: <http://www.geonames.org/ontology#> | ||
SELECT ?kind | ||
WHERE { | ||
?subject gn:featureCode ?kind | ||
} | ||
""" | ||
[[PlaceFromGeonames.attributes]] | ||
# lat | ||
sparql = """ | ||
PREFIX wgs84_pos: <http://www.w3.org/2003/01/geo/wgs84_pos#> | ||
SELECT ?lat | ||
WHERE { | ||
?subject wgs84_pos:lat ?lat. | ||
?subject wgs84_pos:long ?long | ||
} | ||
""" | ||
[[PlaceFromGeonames.attributes]] | ||
# long | ||
sparql = """ | ||
PREFIX wgs84_pos: <http://www.w3.org/2003/01/geo/wgs84_pos#> | ||
SELECT ?long | ||
WHERE { | ||
?subject wgs84_pos:lat ?lat. | ||
?subject wgs84_pos:long ?long | ||
} | ||
""" | ||
[[PlaceFromGeonames.attributes]] | ||
# parent | ||
sparql = """ | ||
PREFIX gn: <http://www.geonames.org/ontology#> | ||
SELECT ?parent | ||
WHERE { | ||
?subject gn:parentCountry ?parent | ||
} | ||
""" | ||
|
||
######################################### | ||
# Create an entity `apis_ontology.Place` | ||
# from a d-nb.info RDF endpoint | ||
######################################### | ||
[PlaceFromDNB] | ||
model = "apis_ontology.Place" | ||
filter_sparql = """ | ||
PREFIX gndo: <https://d-nb.info/standards/elementset/gnd#> | ||
ASK { | ||
?subject gndo:preferredNameForThePlaceOrGeographicName ?object . | ||
} | ||
""" | ||
[[PlaceFromDNB.attributes]] | ||
# name | ||
sparql = """ | ||
PREFIX gndo: <https://d-nb.info/standards/elementset/gnd#> | ||
SELECT ?name | ||
WHERE { | ||
?subject gndo:preferredNameForThePlaceOrGeographicName ?prefName | ||
BIND(?prefName AS ?name) | ||
} | ||
""" | ||
[[PlaceFromDNB.attributes]] | ||
# lon | ||
sparql = """ | ||
PREFIX geo: <http://www.opengis.net/ont/geosparql#> | ||
SELECT ?lon | ||
WHERE { | ||
?subject geo:hasGeometry ?geo1 . | ||
?geo1 geo:asWKT ?point . | ||
BIND(REPLACE(str(?point), "Point . \\+(\\d+\\.\\d+) .+$", "$1") as ?lon) | ||
} | ||
""" | ||
[[PlaceFromDNB.attributes]] | ||
# lat | ||
sparql = """ | ||
PREFIX geo: <http://www.opengis.net/ont/geosparql#> | ||
SELECT ?lat | ||
WHERE { | ||
?subject geo:hasGeometry ?geo1 . | ||
?geo1 geo:asWKT ?point . | ||
BIND(REPLACE(str(?point), "Point . \\+(\\d+\\.\\d+) \\+(\\d+\\.\\d+) .$", "$2") as ?lat) | ||
} | ||
""" | ||
|
||
######################################### | ||
# Create an entity `apis_ontology.Person` | ||
# from a d-nb.info RDF endpoint | ||
######################################### | ||
[PersonFromDNB] | ||
model = "apis_ontology.Person" | ||
filter_sparql = """ | ||
PREFIX gndo: <https://d-nb.info/standards/elementset/gnd#> | ||
ASK { | ||
?subject gndo:preferredNameForThePerson ?object . | ||
} | ||
""" | ||
[[PersonFromDNB.attributes]] | ||
# name | ||
sparql = """ | ||
PREFIX gndo: <https://d-nb.info/standards/elementset/gnd#> | ||
SELECT ?name | ||
WHERE { | ||
?subject gndo:preferredNameForThePerson ?name . | ||
OPTIONAL { | ||
?subject gndo:preferredNameEntityForThePerson ?med . | ||
?med gndo:forename ?first_name. | ||
?med gndo:surname ?name2 . | ||
BIND(?name2 as ?name) | ||
} | ||
BIND(CONCAT(?name, ",", ?first_name) AS ?name) | ||
} | ||
""" | ||
[[PersonFromDNB.attributes]] | ||
# profession | ||
sparql = """ | ||
PREFIX gndo: <https://d-nb.info/standards/elementset/gnd#> | ||
SELECT ?profession | ||
WHERE { | ||
?subject gndo:professionOrOccupation ?profession | ||
} | ||
""" | ||
[[PersonFromDNB.attributes]] | ||
# date_of_birth | ||
sparql = """ | ||
PREFIX gndo: <https://d-nb.info/standards/elementset/gnd#> | ||
SELECT ?date_of_birth | ||
WHERE { | ||
?subject gndo:dateOfBirth ?start_date_written | ||
BIND(?start_date_written AS ?date_of_birth) | ||
} | ||
""" | ||
[[PersonFromDNB.attributes]] | ||
# date_of_death | ||
sparql = """ | ||
PREFIX gndo: <https://d-nb.info/standards/elementset/gnd#> | ||
SELECT ?date_of_death | ||
WHERE { | ||
?subject gndo:dateOfDeath ?end_date_written | ||
BIND(?end_date_written AS ?date_of_death) | ||
} | ||
""" | ||
[[PersonFromDNB.attributes]] | ||
# place_of_birth | ||
sparql = """ | ||
PREFIX gndo: <https://d-nb.info/standards/elementset/gnd#> | ||
SELECT ?place_of_birth | ||
WHERE { | ||
?subject gndo:placeOfBirth ?place_of_birth | ||
} | ||
""" | ||
|
||
############################################## | ||
# Create an entity `apis_ontology.Institution` | ||
# from a d-nb.info RDF endpoint | ||
############################################## | ||
[InstitutionFromDNB] | ||
model = "apis_ontology.Institution" | ||
filter_sparql = """ | ||
PREFIX gndo: <https://d-nb.info/standards/elementset/gnd#> | ||
ASK { | ||
?subject gndo:preferredNameForTheCorporateBody ?object . | ||
} | ||
""" | ||
[[InstitutionFromDNB.attributes]] | ||
# name | ||
sparql = """ | ||
PREFIX gndo: <https://d-nb.info/standards/elementset/gnd#> | ||
SELECT ?name | ||
WHERE { | ||
?subject gndo:preferredNameForTheCorporateBody ?name | ||
} | ||
""" | ||
[[InstitutionFromDNB.attributes]] | ||
# altName | ||
sparql = """ | ||
PREFIX gndo: <https://d-nb.info/standards/elementset/gnd#> | ||
SELECT ?altName | ||
WHERE { | ||
?subject gndo:variantNameForTheCorporateBody ?altName | ||
} | ||
""" | ||
[[InstitutionFromDNB.attributes]] | ||
# place | ||
sparql = """ | ||
PREFIX gndo: <https://d-nb.info/standards/elementset/gnd#> | ||
SELECT ?place | ||
WHERE { | ||
?subject gndo:placeOfBusiness ?place | ||
} | ||
""" | ||
[[InstitutionFromDNB.attributes]] | ||
# start_date_written | ||
sparql = """ | ||
PREFIX gndo: <https://d-nb.info/standards/elementset/gnd#> | ||
SELECT ?start_date_written | ||
WHERE { | ||
?subject gndo:dateOfEstablishment ?start_date_written | ||
} | ||
""" | ||
[[InstitutionFromDNB.attributes]] | ||
# end_date_written | ||
sparql = """ | ||
PREFIX gndo: <https://d-nb.info/standards/elementset/gnd#> | ||
SELECT ?end_date_written | ||
WHERE { | ||
?subject gndo:dateOfTermination ?end_date_written | ||
} | ||
""" |
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