lotus-sparql-examples

A set of SPARQL examples that are used in LOTUS

View the Project on GitHub lotusnprod/lotus-sparql-examples

wd_nps_per_author_scholarly_subgraph

rq turtle/ttl

Count compound-taxon pairs referenced by authors.

Use at


PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdsubgraph: <https://query.wikidata.org/subgraph/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
#title: Count compound-taxon pairs referenced by authors.
#defaultView:BarChart
SELECT ?authors_namesLabel (COUNT(DISTINCT(?compound)) AS ?count) WHERE {
    ?compound p:P703 ?stmt.         # statement found in taxon
    ?stmt prov:wasDerivedFrom ?ref. # get the reference
    ?ref pr:P248 ?art.              # stated in
    VALUES ?authors_names {
        wd:Q56084663                # JLW
        wd:Q40259636                # GFP
        wd:Q1405133                 # A german chemist of the 20th century ... Ferdinand Bohlmann
    }
    SERVICE wdsubgraph:scholarly_articles {
      ?art wdt:P50 ?authors_names.  # limit to references containing the author names
    }
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
}
GROUP BY ?authors_namesLabel
ORDER BY DESC (?count)

graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v5("?art")
  v6("?authors_names")
  v2("?compound"):::projected 
  v7("?count")
  v4("?ref")
  v3("?stmt")
  c7([http://www.bigdata.com/rdf#serviceParam]):::iri 
  c9(["#91;AUTO_LANGUAGE#93;,mul,en"]):::literal 
  v2 --"p:P703"-->  v3
  v3 --"prov:wasDerivedFrom"-->  v4
  v4 --"p:reference/P248"-->  v5
  bind0[/VALUES ?authors_names/]
  bind0-->v6
  bind00(["wd:Q56084663"])
  bind00 --> bind0
  bind01(["wd:Q40259636"])
  bind01 --> bind0
  bind02(["wd:Q1405133"])
  bind02 --> bind0
  subgraph s1["https://query.wikidata.org/subgraph/scholarly_articles"]
    style s1 stroke-width:4px;
    v5 --"p:direct/P50"-->  v6
  end
  subgraph s2["http://wikiba.se/ontology#label"]
    style s2 stroke-width:4px;
    c7 --"wikibase:language"-->  c9
  end
  bind2[/"count(?compound)"/]
  v2 --o bind2
  bind2 --as--o v7