sparql-examples

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

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

242

rq turtle/ttl

Work aspect: cited work 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/Q28942417>

# List of authors with works that are cited by the specified work
SELECT
  ?cited_works

  ?author ?authorLabel ?authorDescription
  (CONCAT("/author/", SUBSTR(STR(?author), 32)) AS ?authorUrl)

  ?cited_work_example ?cited_work_exampleLabel
   (CONCAT("/work/", SUBSTR(STR(?cited_work_example), 32)) AS ?cited_work_exampleUrl)
WITH {
  SELECT
    (COUNT(?cited_work) AS ?cited_works)
    ?author
    (SAMPLE(?cited_work) AS ?cited_work_example)
  WHERE {
    # Find works that are cited by the queried work
    target: wdt:P2860 ?cited_work .
    ?cited_work wdt:P50 ?author .
  }
  GROUP BY ?author
  # Limit the number of results to avoid downloading too much data
  ORDER BY DESC(?cited_works)
  LIMIT 1000
} AS %result
WHERE {
  # Label the result
  INCLUDE %result
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en" . }
}
ORDER BY DESC(?cited_works)
graph TD