Queries: Difference between revisions

From Semantic Name Authority Repository Cymru
Jump to navigation Jump to search
No edit summary
No edit summary
Line 3: Line 3:
== 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)
{{#tag:syntaxhighlight|
{{SPARQL|query=#Returns a list of Wikidata items for a given list of Wikipedia article names
PREFIX wikibase: <http://wikiba.se/ontology#>
#List of Wikipedia article names (lemma) is like "WIKIPEDIA ARTICLE NAME"@LANGUAGE CODE with de for German, en for English, etc.
PREFIX snarcp: <https://snarc-llgc.wikibase.cloud/prop/direct/>
#Language version and project is defined in schema:isPartOF with de.wikipedia.org for German Wikipedia, es.wikivoyage for Spanish Wikivoyage, etc.
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 ?lemma ?item WHERE {
SELECT DISTINCT ?item ?itemLabel ?wikidataid ?libcongid  ?subclas ?subclaslabel ?libcongwikidata WHERE {
  VALUES ?lemma {
   
    "Wikipedia"@de
  ?item snarcp:P45 snarcq:Q63 .
    "Wikidata"@de
   ?item snarcp:P62 ?wikidataid .                             
    "Berlin"@de
   ?item snarcp:P11 ?libcongid
    "Technische Universität Berlin"@de
 
   }
SERVICE <https://query.wikidata.org/sparql>{
   ?sitelink schema:about ?item;
  ?wikidataid wdt:P279 ?subclas.
    schema:isPartOf <https://de.wikipedia.org/>;
  ?subclas rdfs:label ?subclaslabel .
    schema:name ?lemma.
FILTER(LANG(?subclaslabel) = "en"). 
  ?subclas wdt:P244 ?libcongwikidata .
}   
    SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
}
}}
}}

Revision as of 10:52, 26 November 2022

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

Federated query with Wikidata

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

<templatestyles src="SPARQL/styles.css" />

<strong class="error"><span class="scribunto-error" id="mw-scribunto-error-0">Script error: No such module &quot;ConcatArgs&quot;.</span></strong>
Template:Int try it