GOV/SPARQL: Unterschied zwischen den Versionen

aus wiki, dem genealogischen Lexikon zum Mitmachen.
Zur Navigation springen Zur Suche springen
Zeile 121: Zeile 121:
</source>
</source>


[https://gov-sparql.genealogy.net//#PREFIX%20gov%3A%20%3Chttp%3A//gov.genealogy.net/%3E%0APREFIX%20gp%3A%20%3Chttp%3A//gov.genealogy.net/ontology.owl%23%3E%0APREFIX%20gt%3A%20%3Chttp%3A//gov.genealogy.net/types.owl%23%3E%0APREFIX%20rdf%3A%20%3Chttp%3A//www.w3.org/1999/02/22-rdf-syntax-ns%23%3E%0APREFIX%20rdfs%3A%20%3Chttp%3A//www.w3.org/2000/01/rdf-schema%23%3E%0APREFIX%20owl%3A%20%3Chttp%3A//www.w3.org/2002/07/owl%23%3E%0APREFIX%20xsd%3A%20%3Chttp%3A//www.w3.org/2001/XMLSchema%23%3E%0APREFIX%20dc%3A%20%3Chttp%3A//purl.org/dc/terms/%3E%0APREFIX%20dc11%3A%20%3Chttp%3A//purl.org/dc/elements/1.1/%3E%0APREFIX%20skos%3A%20%3Chttp%3A//www.w3.org/2004/02/skos/core%23%3E%0APREFIX%20geo%3A%20%3Chttp%3A//www.opengis.net/ont/geosparql%23%3E%0APREFIX%20foaf%3A%20%3Chttp%3A//xmlns.com/foaf/0.1/%3E%0APREFIX%20time%3A%20%3Chttp%3A//www.w3.org/2006/time%23%3E%0APREFIX%20prov%3A%20%3Chttp%3A//www.w3.org/ns/prov%23%3E%0ASELECT%20%3Fproperty%20%28COUNT%28%2A%29%20AS%20%3Fcount%29%20WHERE%20%7B%0A%20%20%3Fsubject%20%3Fproperty%20%3Fobject%20.%0A%7D%0AGROUP%20BY%20%3Fproperty%0AORDER%20BY%20DESC%28%3Fcount%29%0ALIMIT%2050%0A try it!]
[https://gov-sparql.genealogy.net//?query=PREFIX%20gov%3A%20%3Chttp%3A//gov.genealogy.net/%3E%0APREFIX%20gp%3A%20%3Chttp%3A//gov.genealogy.net/ontology.owl%23%3E%0APREFIX%20gt%3A%20%3Chttp%3A//gov.genealogy.net/types.owl%23%3E%0APREFIX%20rdf%3A%20%3Chttp%3A//www.w3.org/1999/02/22-rdf-syntax-ns%23%3E%0APREFIX%20rdfs%3A%20%3Chttp%3A//www.w3.org/2000/01/rdf-schema%23%3E%0APREFIX%20owl%3A%20%3Chttp%3A//www.w3.org/2002/07/owl%23%3E%0APREFIX%20xsd%3A%20%3Chttp%3A//www.w3.org/2001/XMLSchema%23%3E%0APREFIX%20dc%3A%20%3Chttp%3A//purl.org/dc/terms/%3E%0APREFIX%20dc11%3A%20%3Chttp%3A//purl.org/dc/elements/1.1/%3E%0APREFIX%20skos%3A%20%3Chttp%3A//www.w3.org/2004/02/skos/core%23%3E%0APREFIX%20geo%3A%20%3Chttp%3A//www.opengis.net/ont/geosparql%23%3E%0APREFIX%20foaf%3A%20%3Chttp%3A//xmlns.com/foaf/0.1/%3E%0APREFIX%20time%3A%20%3Chttp%3A//www.w3.org/2006/time%23%3E%0APREFIX%20prov%3A%20%3Chttp%3A//www.w3.org/ns/prov%23%3E%0ASELECT%20%3Fproperty%20%28COUNT%28%2A%29%20AS%20%3Fcount%29%20WHERE%20%7B%0A%20%20%3Fsubject%20%3Fproperty%20%3Fobject%20.%0A%7D%0AGROUP%20BY%20%3Fproperty%0AORDER%20BY%20DESC%28%3Fcount%29%0ALIMIT%2050%0A try it!]
=== result ===
=== result ===
{| class="wikitable" style="text-align: left;"
{| class="wikitable" style="text-align: left;"

Version vom 27. Mai 2025, 09:45 Uhr

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

try it!

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

PropertyHistogram

scripts/govquery PropertyHistogram -f mediawiki

query

SELECT ?property (COUNT(*) AS ?count) WHERE {
  ?subject ?property ?object .
}
GROUP BY ?property
ORDER BY DESC(?count)
LIMIT 50

try it!

result

property count
http://www.w3.org/1999/02/22-rdf-syntax-ns#type 9987544
http://gov.genealogy.net/ontology.owl#value 2798309
http://gov.genealogy.net/ontology.owl#isPartOf 1833097
http://gov.genealogy.net/ontology.owl#ref 1833097
http://gov.genealogy.net/ontology.owl#source 1617950
http://gov.genealogy.net/ontology.owl#sourceRef 1617950
http://gov.genealogy.net/ontology.owl#language 1479497
http://gov.genealogy.net/ontology.owl#hasName 1479496
http://gov.genealogy.net/ontology.owl#timeBegin 1446923
http://gov.genealogy.net/ontology.owl#timeEnd 1423901
http://gov.genealogy.net/ontology.owl#hasType 1370577
http://gov.genealogy.net/ontology.owl#type 1370577
http://gov.genealogy.net/ontology.owl#position 1049392
http://gov.genealogy.net/ontology.owl#positionPrecision 1049392
http://www.opengis.net/ont/geosparql#wktLiteral 1049392
http://www.w3.org/2003/01/geo/wgs84_pos#lat 1049392
http://www.w3.org/2003/01/geo/wgs84_pos#lon 1049392
http://www.w3.org/2002/07/owl#sameAs 864743
http://gov.genealogy.net/ontology.owl#hasPostalCode 457732
http://gov.genealogy.net/ontology.owl#note 452156
http://gov.genealogy.net/ontology.owl#page 452156
http://gov.genealogy.net/ontology.owl#hasPopulation 422664
http://gov.genealogy.net/ontology.owl#hasURL 163517
http://gov.genealogy.net/ontology.owl#hasDenomination 87575
http://gov.genealogy.net/ontology.owl#hasMunicipalityId 74986
http://gov.genealogy.net/ontology.owl#hasArea 50654
http://gov.genealogy.net/ontology.owl#hasWNumber 35660
http://gov.genealogy.net/ontology.owl#hasHouseholds 25991
http://schema.org/name 4934
http://schema.org/url 3985
http://schema.org/alternativeHeadline 1762
http://schema.org/publisher 1741
http://schema.org/author 675
http://schema.org/isbn 100
http://gov.genealogy.net/ontology.owl#hasBuildings 34

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

try it!

result

kreis gemeinde typ typLabel city govid
http://www.wikidata.org/entity/Q21844324 http://www.wikidata.org/entity/Q11700054 http://www.wikidata.org/entity/Q123705 Ortsteil http://www.wikidata.org/entity/Q4981889 NOWDNOKO02MH
http://www.wikidata.org/entity/Q7595612 http://www.wikidata.org/entity/Q63530719 http://www.wikidata.org/entity/Q188509 Stadtteil http://www.wikidata.org/entity/Q649969 ULLLLAQF54FP
http://www.wikidata.org/entity/Q21844324 http://www.wikidata.org/entity/Q11700054 http://www.wikidata.org/entity/Q106935957 http://www.wikidata.org/entity/Q4981889 NOWDNOKO02MH
http://www.wikidata.org/entity/Q2473698 http://www.wikidata.org/entity/Q21636040 http://www.wikidata.org/entity/Q3558970 Dorf in Polen http://www.wikidata.org/entity/Q784921 DOKUDWKO11OW
http://www.wikidata.org/entity/Q2371767 http://www.wikidata.org/entity/Q21843562 http://www.wikidata.org/entity/Q3558970 Dorf in Polen http://www.wikidata.org/entity/Q7686471 TARRNWKO11PH
http://www.wikidata.org/entity/Q2371767 http://www.wikidata.org/entity/Q21843562 http://www.wikidata.org/entity/Q3558970 Dorf in Polen http://www.wikidata.org/entity/Q5950089 HUSNNEKO11WD
http://www.wikidata.org/entity/Q2371767 http://www.wikidata.org/entity/Q21843562 http://www.wikidata.org/entity/Q3558970 Dorf in Polen http://www.wikidata.org/entity/Q6438718 KROOSZKO11QF
http://www.wikidata.org/entity/Q21777323 http://www.wikidata.org/entity/Q61746288 http://www.wikidata.org/entity/Q3558970 Dorf in Polen http://www.wikidata.org/entity/Q5743044 NIEEKIKO12NO
http://www.wikidata.org/entity/Q20859217 http://www.wikidata.org/entity/Q9273753 http://www.wikidata.org/entity/Q3558970 Dorf in Polen http://www.wikidata.org/entity/Q3692447 GRAIECKO12MS
http://www.wikidata.org/entity/Q880888 http://www.wikidata.org/entity/Q81727403 http://www.wikidata.org/entity/Q3558970 Dorf in Polen http://www.wikidata.org/entity/Q5618459 OSINKAKO12SU