A set of SPARQL examples that are used in LOTUS
Most popular natural products by count of items named after them.
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#>
#title: Most popular natural products by count of items named after them.
SELECT DISTINCT ?np ?npLabel (COUNT(DISTINCT ?item) AS ?count) WHERE {
?item wdt:P138 ?np.
?np p:P703 [];
wdt:P2067 ?mass;
wdt:P274 ?formula.
FILTER (?mass > 100) # Removes compounds such as water, ethanol, etc.
FILTER(STRLEN(?formula) > 2) # Removes pure substances
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
}
GROUP BY ?np ?npLabel
ORDER BY DESC (?count)
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?count")
v2("?formula")
v4("?item"):::projected
v3("?mass")
v5("?np"):::projected
a1((" "))
c8([http://www.bigdata.com/rdf#serviceParam]):::iri
c10(["#91;AUTO_LANGUAGE#93;,mul,en"]):::literal
f0[["string-length(?formula) > '2^^xsd:integer'"]]
f0 --> v2
f1[["?mass > '100^^xsd:integer'"]]
f1 --> v3
v4 --"p:direct/P138"--> v5
v5 --"p:P703"--> a1
v5 --"p:direct/P2067"--> v3
v5 --"p:direct/P274"--> v2
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c8 --"wikibase:language"--> c10
end
bind3[/"count(?item)"/]
v4 --o bind3
bind3 --as--o v6