A set of SPARQL examples that are used in LOTUS
Dishes with ingredients found in the most diverse taxa.
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX hint: <http://www.bigdata.com/queryHints#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
#title: Dishes with ingredients found in the most diverse taxa.
SELECT DISTINCT ?dish ?dishLabel (COUNT(DISTINCT ?ingredient) AS ?ingredients) (COUNT(DISTINCT ?parent) AS ?parents) WHERE {
{
SELECT DISTINCT ?dish ?dishLabel ?ingredient ?taxon WHERE {
{
SELECT DISTINCT ?dish ?dishLabel ?ingredient WHERE {
# modelling is not perfect
VALUES ?approx_dish {
wd:Q746549
wd:Q19861951
}
hint:Query hint:optimizer "None".
?dish wdt:P31 ?approx_dish;
# modelling is not perfect
(wdt:P527+|wdt:P186+) ?ingredient.
hint:Prior hint:gearing "forward".
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en".
?dish rdfs:label ?dishLabel.
}
}
}
?ingredient (wdt:P186*) ?subingredient.
{
?subingredient wdt:P31 wd:Q16521.
BIND(?subingredient AS ?taxon)
}
UNION
{ ?subingredient wdt:P1582 ?taxon. }
}
}
?taxon (wdt:P171*) ?parent.
}
GROUP BY ?dish ?dishLabel
ORDER BY DESC (?parents)
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v2("?approx_dish")
v3("?dish"):::projected
v5("?dishLabel"):::projected
v4("?ingredient"):::projected
v9("?ingredients")
v8("?parent"):::projected
v10("?parents")
v6("?subingredient")
v7("?taxon")
c7([http://www.bigdata.com/queryHints#Prior]):::iri
c9(["forward"]):::literal
c13(["#91;AUTO_LANGUAGE#93;,mul,en"]):::literal
c11([http://www.bigdata.com/rdf#serviceParam]):::iri
c1([http://www.bigdata.com/queryHints#Query]):::iri
c15(["wd:Q16521"]):::iri
c3(["None"]):::literal
bind0[/VALUES ?approx_dish/]
bind0-->v2
bind00(["wd:Q746549"])
bind00 --> bind0
bind01(["wd:Q19861951"])
bind01 --> bind0
c1 --http://www.bigdata.com/queryHints#optimizer--> c3
v3 --"wdt:P31"--> v2
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v3 --"wdt:P186"--> v4
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v3 --"wdt:P527"--> v4
end
union0r <== or ==> union0l
end
c7 --http://www.bigdata.com/queryHints#gearing--> c9
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c11 --"wikibase:language"--> c13
v3 --"rdfs:label"--> v5
end
v4 --"wdt:P186"--> v6
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
v6 --"wdt:P1582"--> v7
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v6 --"wdt:P31"--> c15
bind1[/"?subingredient"/]
v6 --o bind1
bind1 --as--o v7
end
union1r <== or ==> union1l
end
v7 --"wdt:P171"--> v8
bind4[/"count(?ingredient)"/]
v4 --o bind4
bind4 --as--o v9
bind5[/"count(?parent)"/]
v8 --o bind5
bind5 --as--o v10