Reputation: 31
ok, let's say that I need to extract all those recipes containing 2/3 ingredients. The recipes are represented as linked data and this is the ontology used http://linkedrecipes.org/schema. I know how to find recipes with curry:
PREFIX rdfs: <htp://ww.w3.org/2000/01/rdf-schema#>
PREFIX recipe: <htp://linkedrecipes.org/schema/>
SELECT ?label ?recipe
WHERE{
?food rdfs:label ?label2 .
?food recipe:ingredient_of ?recipe .
?recipe a recipe:Recipe .
?recipe rdfs:label ?label.
FILTER (REGEX(STR(?label2), 'curry', 'i'))
}
But how can i find recipes with curry and chicken for example?
Upvotes: 1
Views: 337
Reputation: 9482
This should find curry and chicken:
PREFIX rdfs: <htp://ww.w3.org/2000/01/rdf-schema#>
PREFIX recipe: <htp://linkedrecipes.org/schema/>
SELECT ?label ?recipe {
?recipe a recipe:Recipe .
?recipe rdfs:label ?label.
?curry recipe:ingredient_of ?recipe .
?curry rdfs:label ?curry_label .
FILTER (REGEX(STR(?curry_label), 'curry', 'i'))
?chicken recipe:ingredient_of ?recipe .
?chicken rdfs:label ?chicken_label .
FILTER (REGEX(STR(?chicken_label), 'chicken', 'i'))
}
Upvotes: 1