User:Charles Matthews/SPARQL workshop 12 May 2019

Links for SPARQL workshop, 12 May 2019 in Makespace classroom, see m:Meetup/Cambridge/41.

IntroductoryEdit

Query to try in WD-FIST:

#Female scientists
SELECT ?item
  WHERE {?item wdt:P31 wd:Q5;
               wdt:P21 wd:Q6581072;
               wdt:P106 wd:Q901.}

Try it!

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" }
}

Try it!

#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" }
}

Try it!

#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" }
}

Try it!

Journal queries and dataEdit

#Subclasses of "scholarly article"
SELECT DISTINCT ?pubtype ?pubtypeLabel 
  WHERE {?pubtype wdt:P279* wd:Q13442814.
        SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
        }

Try it!

#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)

Try it!

#Listing focus lists
SELECT DISTINCT ?project ?projectLabel 
  WHERE {?item wdt:P5008 ?project.
        SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
        }

Try it!

#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)

Try it!

#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)

Try it!

ScienceSourceEdit