User:Charles Matthews/SPARQL workshop 12 May 2019
Links for SPARQL workshop, 12 May 2019 in Makespace classroom, see m:Meetup/Cambridge/41.
Introductory edit
- User:Charles Matthews/SPARQL resources
- User:Charles Matthews/Queries
- Tools using Wikidata SPARQL: WD-FIST, Listeria, PetScan
Query to try in WD-FIST:
#Female scientists
SELECT ?item
WHERE {?item wdt:P31 wd:Q5;
wdt:P21 wd:Q6581072;
wdt:P106 wd:Q901.}
- Views
#Canidae mapped by genus and species.
#defaultView:TreeMap
SELECT ?family ?familyLabel ?genus ?genusLabel ?species ?speciesLabel
WHERE
{
BIND(wd:Q25324 AS ?family) .
?species wdt:P171 ?genus.
?genus wdt:P171 ?family.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
#Libraries of the world
#defaultView:Map
SELECT ?library ?coord
WHERE {
?library wdt:P31 wd:Q7075 .
OPTIONAL { ?library wdt:P625 ?coord }
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
#Parent taxons for E. Coli, graph display
#defaultView:Graph
SELECT ?item ?itemLabel ?pic ?linkTo
WHERE
{
wd:Q25419 wdt:P171* ?item
OPTIONAL { ?item wdt:P171 ?linkTo }
OPTIONAL { ?item wdt:P18 ?pic }
SERVICE wikibase:label {bd:serviceParam wikibase:language "en" }
}
Journal queries and data edit
#Subclasses of "scholarly article"
SELECT DISTINCT ?pubtype ?pubtypeLabel
WHERE {?pubtype wdt:P279* wd:Q13442814.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
#Counting focus list journals by number of statements
SELECT DISTINCT ?journal ?journalLabel ?statementcount
WHERE {?item wdt:P5008 wd:Q55439927;
wdt:P1433 ?journal.
?journal wikibase:statements ?statementcount.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY DESC(?statementcount)
#Listing focus lists
SELECT DISTINCT ?project ?projectLabel
WHERE {?item wdt:P5008 ?project.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
#Listing focus lists, numerical
SELECT ?projectLabel (COUNT(?item) AS ?count)
WHERE {?item wdt:P5008 ?project.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?projectLabel
ORDER BY DESC(?count)
#defaultView:BubbleChart
#Focus list journals without publishers
SELECT ?journalLabel (COUNT(?article) AS ?count)
WHERE {?article wdt:P5008 wd:Q55439927;
wdt:P1433 ?journal.
MINUS {?journal wdt:P123 ?publisher}.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?journalLabel
ORDER BY DESC(?count)
ScienceSource edit
- Wikidata:ScienceSource project/Project tools
- Wikidata talk:ScienceSource project/Queries#NDF-RT issue: query uses the p:, pr:, ps: and prov: prefixes, to identify statements referenced to a particular database. See mw:Wikibase/Indexing/RDF Dump Format for fuller details. See Wikidata talk:WikiProject Medicine#medical condition treated (P2175) matters for where this arises.