Questions SPARQL Queries

Competency Questions

Setting Example Competency Question Candidate Answer
Contextual (Q1). Why should I eat Cauliflower Potato Curry? Cauliflower Potato Curry uses ingredient Cauliflower, which is available in the current season.
Contrastive (Q2). Why should I eat Butternut Squash Soup over a Broccoli Cheddar Soup? Butternut Squash Soup is better than a Broccoli Cheddar Soup because Butternut Squash Soup is currently in season, and you are allergic to Broccoli Cheddar Soup.
Counterfactual (Q3).What if I was pregnant? If you were pregnant, you would beforbidden from eating sushi. You would be suggested toeat Spinach Frittata.
Statistical (Q4).Why should I follow a low calorie diet? 66.67% percent of people how followed a low calorie diet lost weight, which is one of your goals.

SPARQL Queries

  1. Why should I eat Cauliflower Potato Curry?
    • Query:
      PREFIX feo: <http://purl.org/heals/food-explanation-ontology/>
      PREFIX eo: <http://purl.org/heals/eo#>
      PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
      
      SELECT DISTINCT ?characteristic ?classes
      WHERE{
        ?WhyEatCauliflowerPotatoCurry feo:hasParameter ?parameter .
        ?parameter feo:hasCharacteristic ?characteristic .
        ?characteristic feo:isInternal False .
        ?systemChar a feo:SystemCharacteristic .
        ?userChar a feo:UserCharacteristic .
        filter ( ?characteristic = ?systemChar || ?characteristic = ?userChar ) .
        ?characteristic a ?classes .
        ?classes rdfs:subClassOf feo:Characteristic .
        Filter Not Exists{?classes rdfs:subClassOf <https://purl.org/heals/eo#knowledge> }.
      }
            
    • Answer
      Characteristic Classes
      Autumn SeasonCharacteristic
  2. Why should I eat Butternut Squash Soup over a Broccoli Cheddar Soup?
    • Query:
      PREFIX food: <http://purl.org/heals/food/>
      PREFIX eo: <http://purl.org/heals/eo#>
      PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
      
      Select DISTINCT ?factType ?factA ?foilType ?foilB
      Where{
        ?question feo:hasPrimaryParameter ?parameterA .
        ?question feo:hasSecondaryParameter ?parameterB .
      
        ?parameterA feo:hasCharacteristic ?factA .
        ?factA a <https://purl.org/heals/eo#Fact>.
        ?factA a ?factType .
        ?factType (rdfs:subClassOf+) feo:Characteristic .
        Filter Not Exists{?factType rdfs:subClassOf <https://purl.org/heals/eo#knowledge> }.
        Filter Not Exists{?s rdfs:subClassOf ?factType}.
        
        ?parameterB feo:hasCharacteristic ?foilB .
        ?foilB a <https://purl.org/heals/eo#Foil> .
        ?foilB a ?foilType.
        ?foilType (rdfs:subClassOf+) feo:Characteristic .
        Filter Not Exists{?foilType rdfs:subClassOf <https://purl.org/heals/eo#knowledge> }.
        Filter Not Exists{?t rdfs:subClassOf ?foilType}.
      
      }
            
    • Answer
      FactType FactA FoilType FoilB
      SeasonCharacteristic Autumn AllergicFoodCharacteristic Broccoli
  3. What if I was pregnant?
    • Query:
      PREFIX feo: <http://purl.org/heals/food-explanation-ontology/>
      PREFIX food: <http://purl.org/heals/food/>
      PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
      
      SELECT Distinct ?property ?ingredient ?outputs
      WHERE{
        feo:WhatIfIWasPregnant  feo:hasParameter ?parameter .
        ?parameter ?property  ?ingredient .
        ?property rdfs:subPropertyOf feo:isCharacteristicOf.
        ?ingredient a food:Food .
        OPTIONAL { ?ingredient feo:isIngredientOf ?outputs.}
      }
            
    • Answer
      Property Base Food Inherited Food
      recommends Spinach Spinach Frittata
      forbids Sushi
  4. Why should I follow a low calorie diet?
    • Query:
      PREFIX feo: <http://purl.org/heals/food-explanation-ontology/>
      PREFIX eo: <http://purl.org/heals/eo#>
      
      SELECT DISTINCT ?goal ((Count( distinct ?accomplishedUsers))/(Count( distinct ?allOtherUsers)) as ?percentAccomplished)
      WHERE{
        ?WhyFollowLowCalorieDiet feo:hasParameter ?diet.
        ?WhyFollowLowCalorieDiet feo:askedBy ?mainUser.
        ?mainUser feo:hasGoal ?goal.
        ?allOtherUsers feo:hasDiet ?diet .
        FILTER ( ?allOtherUsers != ?mainUser ).
        ?accomplishedUsers feo:hasDiet ?diet .
        ?accomplishedUsers feo:accomplishedGoal ?goal.
      }
      GROUP BY ?goal
      Having ((Count( distinct ?accomplishedUsers))/(Count( distinct ?allOtherUsers)) >= .5)
            
    • Answer
      Goal Base Food
      Weight Loss .6667