Skip to content

Commit

Permalink
fix: add more sameAs
Browse files Browse the repository at this point in the history
  • Loading branch information
sennierer committed Dec 13, 2024
1 parent bd0d617 commit 918c45c
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apis_ontology/rdfimport/EventFromDNB.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,13 @@ WHERE {
gndo:place ?relatedPlace__Place__FandStattIn .
}
"""
[[attributes]]
# sameAs
sparql = '''
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT (GROUP_CONCAT(?sameas_pre; separator='|') as ?sameas)
WHERE {
?subject owl:sameAs ?sameas_pre
}
GROUP BY ?subject
'''
10 changes: 10 additions & 0 deletions apis_ontology/rdfimport/InstitutionFromWikidata.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,13 @@ WHERE {
BIND(COALESCE(?label_de, ?label_en, ?label) AS ?name)
}
"""
[[attributes]]
# sameAs
sparql = '''
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT (GROUP_CONCAT(?sameas_pre; separator='|') as ?sameas)
WHERE {
?subject wdtn:P227|wdtn:P1566|wdtn:P214|wdtn:P244 ?sameas_pre
}
GROUP BY ?subject
'''
22 changes: 22 additions & 0 deletions apis_ontology/rdfimport/PersonFromWikidata.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@
##############################################
superclass = "apis_ontology.models.Person"
regex = "http://www.wikidata.org.*"
sameas = """
PREFIX wdtn: <http://www.wikidata.org/prop/direct-normalized/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
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 = """
Expand Down Expand Up @@ -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: <http://www.w3.org/2002/07/owl#>
SELECT (GROUP_CONCAT(?sameas_pre; separator='|') as ?sameas)
WHERE {
?subject wdtn:P227|wdtn:P1566|wdtn:P214|wdtn:P244 ?sameas_pre
}
GROUP BY ?subject
'''
57 changes: 57 additions & 0 deletions apis_ontology/rdfimport/PlaceFromWikidata.toml
Original file line number Diff line number Diff line change
@@ -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: <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 }
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: <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)
}
'''
[[attributes]]
# sameAs
sparql = '''
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT (GROUP_CONCAT(?sameas_pre; separator='|') as ?sameas)
WHERE {
?subject wdtn:P227|wdtn:P1566|wdtn:P214|wdtn:P244 ?sameas_pre
}
GROUP BY ?subject
'''

0 comments on commit 918c45c

Please sign in to comment.