GOV/SPARQL
Zur Navigation springen
Zur Suche springen
Hier werden SPARQL Abfragen mit GOV und Wikidata erklärt.
GOV
Interaktiv können Abfragen unter https://gov-sparql.genealogy.net/ eingegeben werden.
Prefixes
Die folgenden PREFIX Deklarationen müssen den Abfragen ggf. voran gestellt werden.
PREFIX gov: <http://gov.genealogy.net/>
PREFIX gp: <http://gov.genealogy.net/ontology.owl#>
PREFIX gt: <http://gov.genealogy.net/types.owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX dc: <http://purl.org/dc/terms/>
PREFIX dc11: <http://purl.org/dc/elements/1.1/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX time: <http://www.w3.org/2006/time#>
PREFIX prov: <http://www.w3.org/ns/prov#>
Im Folgenden sind einige Beispielabfragen aufgeführt, die auch im GenWiki2024 Prototyp ausprobiert werden können. Die Liste der Beispielqueries im YAML Format für Named Parameterized Queries wird dafür genutzt. Die Queries lassen sich auch per Kommandozeile ausführen.
git clone https://github.com/WolfgangFahl/genwiki2024
scripts/govquery --list
KirchenkreiseNordkirche:KirchenkreiseNordkirche
W2306Koordinaten:W2306Koordinaten
ObjectsByType:ObjectsByType
ObjectHierarchy:ObjectHierarchy
ObjectsInRegion:ObjectsInRegion
ObjectsWithCoordinates:ObjectsWithCoordinates
ObjectsWithWikidata:ObjectsWithWikidata
HistoricalNames:HistoricalNames
PopulationHistory:PopulationHistory
SearchByPattern:SearchByPattern
SearchByWNumber:SearchByWNumber
ObjectsInCoordinateRange:ObjectsInCoordinateRange
PropertyHistogram:PropertyHistogram
KirchenkreiseNordkirche
scripts/govquery KirchenkreiseNordkirche "limit=20" -f mediawiki
query
SELECT DISTINCT ?kk ?name ?qid
WHERE {
?kk gp:hasType/gp:type gt:27 .
?kk gp:hasName/gp:value ?name .
?kk (gp:isPartOf/gp:ref)* gov:object_398036 .
OPTIONAL {
?kk owl:sameAs ?qid .
FILTER(STRSTARTS(STR(?qid),"http://www.wikidata.org/wiki/"))
}
}
ORDER BY ?name
LIMIT 20
result
kk | name | qid |
---|---|---|
http://gov.genealogy.net/object_398074 | Altholstein | |
http://gov.genealogy.net/object_398072 | Dithmarschen | |
http://gov.genealogy.net/object_398078 | Hamburg-Ost | |
http://gov.genealogy.net/object_398079 | Hamburg-West/Südholstein | |
http://gov.genealogy.net/object_398080 | Lübeck-Lauenburg | |
http://gov.genealogy.net/object_398060 | Mecklenburg | |
http://gov.genealogy.net/object_1085568 | Nordfriesland | http://www.wikidata.org/wiki/Q114353690 |
http://gov.genealogy.net/object_397368 | Ostholstein | |
http://gov.genealogy.net/object_398076 | Plön-Segeberg | |
http://gov.genealogy.net/object_398061 | Pommern | |
http://gov.genealogy.net/object_398075 | Rantzau-Münsterdorf | |
http://gov.genealogy.net/object_398073 | Rendsburg-Eckernförde | |
http://gov.genealogy.net/object_398071 | Schleswig-Flensburg |
Wikidata
Das Property P2503 GOV-Kennung dient zur Verknüpfung von Wikidata Einträgen mit GOV Objekten
GOVOrte
scripts/wdquery GOVOrte "lang=de,limit=10" -f mediawiki
query
SELECT ?kreis ?kreisLabel ?gemeinde ?gemeindeLabel ?typ ?typLabel ?city ?cityLabel ?govid
WHERE {
?city wdt:P2503 ?govid ;
wdt:P131 ?gemeinde ;
wdt:P31 ?typ .
?gemeinde wdt:P131 ?kreis .
OPTIONAL { ?city rdfs:label ?cityLabel . FILTER(LANG(?cityLabel) = "de") }
OPTIONAL { ?gemeinde rdfs:label ?gemeindeLabel . FILTER(LANG(?gemeindeLabel) = "de") }
OPTIONAL { ?kreis rdfs:label ?kreisLabel . FILTER(LANG(?kreisLabel) = "de") }
OPTIONAL { ?typ rdfs:label ?typLabel . FILTER(LANG(?typLabel) = "de") }
}
ORDER BY ?kreisLabel ?gemeindeLabel ?cityLabel
LIMIT 10