sparql-examples

A set of SPARQL examples that are used in different TGX resources

View the Project on GitHub BiGCAT-UM/sparql-examples

119

rq turtle/ttl

Organization aspect: topics

Use at

PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX target: <http://www.wikidata.org/entity/Q104785223>

SELECT
  ?researchers
  ?topic ?topicLabel (CONCAT("/topic/", SUBSTR(STR(?topic), 32)) AS ?topicUrl)
  ("🔎" AS ?zoom)
  (CONCAT("Q104785223/topic/", SUBSTR(STR(?topic), 32)) AS ?zoomUrl)
  ?topicDescription
  ?samplework ?sampleworkLabel (CONCAT("/work/", SUBSTR(STR(?samplework), 32)) AS ?sampleworkUrl)
WITH {
  SELECT DISTINCT ?researcher WHERE {
    ?researcher ( wdt:P108 | wdt:P463 | wdt:P1416 ) / wdt:P361* target: .
  } 
} AS %researchers
WITH {
  SELECT DISTINCT ?topic
    (COUNT(DISTINCT ?researcher) AS ?researchers)
    (SAMPLE(?work) AS ?samplework)
  WHERE {
    INCLUDE %researchers
    ?work wdt:P50 ?researcher . 
    ?work wdt:P921 ?topic . 
  } 
  GROUP BY ?topic
  ORDER BY DESC(?researchers)
  LIMIT 500
} AS %works_and_number_of_researchers
WHERE {
  INCLUDE %works_and_number_of_researchers
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" . } 
}
GROUP BY ?researchers ?topic ?topicLabel ?topicDescription ?samplework ?sampleworkLabel
ORDER BY DESC(?researchers)

graph TD