Queries: Difference between revisions

From Semantic Name Authority Repository Cymru
Jump to navigation Jump to search
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Template:Mainpage}}
Enghreifftiau o queries a ddefnyddiwyd i dynnu data o'r gronfa / ''Examples of queries used to extract data from the database''
Enghreifftiau o queries a ddefnyddiwyd i dynnu data o'r gronfa / ''Examples of queries used to extract data from the database''
== SNARC Queries ==
* [https://snarc-llgc.wikibase.cloud/query/#PREFIX%20wikibase%3A%20%3Chttp%3A%2F%2Fwikiba.se%2Fontology%23%3E%0APREFIX%20snarcp%3A%20%3Chttps%3A%2F%2Fsnarc-llgc.wikibase.cloud%2Fprop%2Fdirect%2F%3E%0APREFIX%20snarcq%3A%20%3Chttps%3A%2F%2Fsnarc-llgc.wikibase.cloud%2Fentity%2F%3E%0APREFIX%20wdt%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2F%3E%0APREFIX%20wd%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fentity%2F%3E%0APREFIX%20bd%3A%20%3Chttp%3A%2F%2Fwww.bigdata.com%2Frdf%23%3E%0APREFIX%20rdfs%3A%20%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0A%0A%0ASELECT%20DISTINCT%20%3Fitem%20%3FitemLabel%20%20WHERE%20%7B%0A%20%20%0A%3Fitem%20snarcp%3AP2%20%3Fid%0A%20%20%0AFILTER%20NOT%20EXISTS%20%7B%20%3Fitem%20rdfs%3Alabel%20%3Flabel_cy%20filter%20%28lang%28%3Flabel_cy%29%20%3D%20%22cy%22%29.%7D%0A%20%20%0A%0A%20%20%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22.%20%7D%0A%7D Check for items with no CY label]
* [https://snarc-llgc.wikibase.cloud/query/#PREFIX%20wikibase%3A%20%3Chttp%3A%2F%2Fwikiba.se%2Fontology%23%3E%0APREFIX%20snarcp%3A%20%3Chttps%3A%2F%2Fsnarc-llgc.wikibase.cloud%2Fprop%2Fdirect%2F%3E%0APREFIX%20snarcq%3A%20%3Chttps%3A%2F%2Fsnarc-llgc.wikibase.cloud%2Fentity%2F%3E%0APREFIX%20wdt%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2F%3E%0APREFIX%20wd%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fentity%2F%3E%0APREFIX%20bd%3A%20%3Chttp%3A%2F%2Fwww.bigdata.com%2Frdf%23%3E%0APREFIX%20rdfs%3A%20%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0A%0A%0ASELECT%20DISTINCT%20%3Fitem%20%3FitemLabel%20%3Fid%20WHERE%20%7B%0A%0A%20%20%3Fitem%20snarcp%3AP26%20%3Fcoords%20.%0A%3Fitem%20snarcp%3AP2%20%3Fid%20.%0A%20%20FILTER%20NOT%20EXISTS%20%7B%20%3Fitem%20snarcp%3AP63%20snarcq%3AQ1%20%7D%20.%0A%20%20%0A%0A%20%20%0A%0A%20%20%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22.%20%7D%0A%7D Places outside of Wales]
* [https://snarc-llgc.wikibase.cloud/query/embed.html#%23defaultView%3AGraph%0A%0APREFIX%20wikibase%3A%20%3Chttp%3A%2F%2Fwikiba.se%2Fontology%23%3E%0APREFIX%20snarcp%3A%20%3Chttps%3A%2F%2Fsnarc-llgc.wikibase.cloud%2Fprop%2Fdirect%2F%3E%0APREFIX%20snarcq%3A%20%3Chttps%3A%2F%2Fsnarc-llgc.wikibase.cloud%2Fentity%2F%3E%0APREFIX%20wdt%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2F%3E%0APREFIX%20wd%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fentity%2F%3E%0APREFIX%20bd%3A%20%3Chttp%3A%2F%2Fwww.bigdata.com%2Frdf%23%3E%0APREFIX%20rdfs%3A%20%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0A%0A%0ASELECT%20DISTINCT%20%3Fitem%20%3FitemLabel%20%3Ftype%20%3FtypeLabel%20WHERE%20%7B%0A%3Fitem%20snarcp%3AP45%20%3Ftype%20.%20%20%20%0A%3Fitem%20snarcp%3AP45%2B%20snarcq%3AQ10431%20.%0A%0A%0A%20%20%0A%0A%20%20%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22.%20%7D%0A%7D Subclass Hiararchy Graph]


== Federated query with Wikidata ==
== Federated query with Wikidata ==
# Occupations from SNARC with additional information on Subclass from Wikidata (Library of congress ID from both)
==== Occupations from SNARC with additional information on Subclass from Wikidata (Library of congress ID from both) ====
{{SPARQL|query=#Returns a list of Wikidata items for a given list of Wikipedia article names
#List of Wikipedia article names (lemma) is like "WIKIPEDIA ARTICLE NAME"@LANGUAGE CODE with de for German, en for English, etc.
#Language version and project is defined in schema:isPartOF with de.wikipedia.org for German Wikipedia, es.wikivoyage for Spanish Wikivoyage, etc.


SELECT ?lemma ?item WHERE {
<syntaxhighlight lang="sparql">
  VALUES ?lemma {
 
    "Wikipedia"@de
PREFIX wikibase: <http://wikiba.se/ontology#>
    "Wikidata"@de
PREFIX snarcp: <https://snarc-llgc.wikibase.cloud/prop/direct/>
    "Berlin"@de
PREFIX snarcq: <https://snarc-llgc.wikibase.cloud/entity/>
    "Technische Universität Berlin"@de
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
   }
PREFIX wd: <http://www.wikidata.org/entity/>
   ?sitelink schema:about ?item;
PREFIX bd: <http://www.bigdata.com/rdf#>
    schema:isPartOf <https://de.wikipedia.org/>;
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
     schema:name ?lemma.
 
 
SELECT DISTINCT ?item ?itemLabel ?wikidataid ?libcongid  ?subclas ?subclaslabel ?libcongwikidata WHERE {
   
  ?item snarcp:P7 snarcq:Q63 .
   ?item snarcp:P62 ?wikidataid .                             
   ?item snarcp:P11 ?libcongid
 
SERVICE <https://query.wikidata.org/sparql>{
  ?wikidataid wdt:P279 ?subclas.
  ?subclas rdfs:label ?subclaslabel .
FILTER(LANG(?subclaslabel) = "en"). 
  ?subclas wdt:P244 ?libcongwikidata .
}      
    SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
}
}}
 
</syntaxhighlight>

Latest revision as of 16:15, 31 January 2023

Enghreifftiau o queries a ddefnyddiwyd i dynnu data o'r gronfa / Examples of queries used to extract data from the database

SNARC Queries

Federated query with Wikidata

Occupations from SNARC with additional information on Subclass from Wikidata (Library of congress ID from both)

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX snarcp: <https://snarc-llgc.wikibase.cloud/prop/direct/>
PREFIX snarcq: <https://snarc-llgc.wikibase.cloud/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>


SELECT DISTINCT ?item ?itemLabel ?wikidataid ?libcongid  ?subclas ?subclaslabel ?libcongwikidata WHERE {
     
   ?item snarcp:P7 snarcq:Q63 . 
  ?item snarcp:P62 ?wikidataid .                               
  ?item snarcp:P11 ?libcongid
  
SERVICE <https://query.wikidata.org/sparql>{
  ?wikidataid wdt:P279 ?subclas.
  ?subclas rdfs:label ?subclaslabel .
 FILTER(LANG(?subclaslabel) = "en").  
  ?subclas wdt:P244 ?libcongwikidata .
}     
    SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}