sparql-examples

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

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

141

rq turtle/ttl

Project aspect: prolific authors

Use at

PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
# Prolific authors for a specific project
PREFIX target: <http://www.wikidata.org/entity/Q27990087>

SELECT ?count ?author ?authorLabel ?orcid ?example_work ?example_workLabel
WITH {
  SELECT DISTINCT ?work WHERE {
    {
      ?work wdt:P921 / (wdt:P527+ | wdt:P1269+ | (wdt:P31* / wdt:P279*) ) target: .
    } UNION { ?work wdt:P859/(wdt:P1344|^wdt:P710)* target: .
    } UNION {
      target: ?propp ?statement .
      ?statement a wikibase:BestRank ;
                 prov:wasDerivedFrom/pr:P248 ?work .
    }
  }
} AS %works
WITH {
  SELECT
    ?author
    (COUNT(?work) AS ?count)
    (SAMPLE(?work) AS ?example_work)
  WHERE {
    INCLUDE %works
    ?work wdt:P50 ?author .
  }
  GROUP BY ?author
} AS %result
WHERE {
  INCLUDE %result
          
  # Include optional ORCID iD
  OPTIONAL { ?author wdt:P496 ?orcid . }
  
  # Label the results
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" . }
}
ORDER BY DESC(?count)
LIMIT 50
graph TD