sparql-examples

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

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

010

rq turtle/ttl

Author aspect: most citing authors

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#>
#defaultView:Table
PREFIX target: <http://www.wikidata.org/entity/Q97270>

SELECT
  ?count
  ?citing_author ?citing_authorLabel

  # Either show the ORCID iD or construct part of a URL to search on the ORCID homepage
  (COALESCE(?orcid_, CONCAT("orcid-search/search/?searchQuery=", ENCODE_FOR_URI(?citing_authorLabel))) AS ?orcid)
WITH {
  SELECT (COUNT(?citing_work) AS ?count) ?citing_author WHERE {
    ?work wdt:P50 target: .
    ?citing_work wdt:P2860 ?work . 
    MINUS { ?citing_work wdt:P50 target: }
    ?citing_work wdt:P50 ?citing_author .
  }
  GROUP BY ?citing_author 
  ORDER BY DESC(?count)
  LIMIT 500
} AS %counts
WITH {
  # An author might have multiple ORCID iDs
  SELECT
    ?count
    ?citing_author
    (SAMPLE(?orcids) AS ?orcid_)
  WHERE {
    INCLUDE %counts
    OPTIONAL { ?citing_author wdt:P496 ?orcids }
  }
  GROUP BY ?count ?citing_author
} AS %result
WHERE {
  INCLUDE %result
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" . }
} 
ORDER BY DESC(?count)

graph TD