...
Create a rule to return N, the number of steps for a certain RecipeID. HINT: your groupmates should have made a recipeSteps function that could help.
...
diet
Code Block |
---|
diet(RecipeID, DietaryRestriction) :- |
...
The ingredientsMeetDiet predicate is our stop clause, which will recursively check each ingredient and return ‘false’ when an ingredient does not meet the given dietary restriction. The predicate ‘typeIngredient’ can be used to check if an ingredient meets a dietary restriction. Fill in the body of the rule for ingredientsMeetDiet.
...
easyRecipe
Code Block |
---|
easyRecipe(RecipeID) :- |
...
it can be made within 45 minutes,
it has less than 18 steps, and
it has less than 15 ingredients
Recipe Filtering Functions
...
Functions
These functions filter our recipes and return a list of filtered recipes in the form of their RecipeIDs. The heads of the rules are in the recipe_selection.pl file.
There are different variants that you need to implement of the ‘applyFilter’ rule, depending on the filter that needs to be applied - filtering for cuisine asks for a different function than filtering for duration. These variants are specified in the table below.
applyFilter
Code Block |
---|
applyFilter(+ParamName, +Value, +RecipeIDs, -FilteredRecipes) |
Filters the recipes provided as input using the (Key) feature with associated value and returns the recipes that satisfy the feature as output.
ParamName: A parameter name referring to a feature that the recipes should have (ex.for example: ’cuisine’).
Value: The associated value of the recipe feature (parameter name) (The user requested filter value like Chinesefor example: ‘Chinese’).
RecipeIDs: The recipes that need to be filtered.
FilteredRecipes: The recipes that have the required feature.
Thus, you must find all recipes that fit the filter criteria and return a list of the filtered recipes. Make sure to use the naming conventions for the variables that we provided. For the first two functions, I we shall provide some hints. These hints could apply to more than one applyFilter ‘applyFilter’ rule. The heads can be found in recipe_selection.pl.
A list of all your applyFilter ‘applyFilter’ functions and some notes on how to create them:
Predicate Description | Rule Head | Notes/Instructions |
---|---|---|
The predicate to filter recipes on cuisines (e.g., Italian recipes) | applyFilter('cuisine', Value, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes that meet the dietary restrictions (vegetarian etcsuch as ‘vegetarian’). | applyFilter('dietaryrestriction', Value, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes on the max amount of time | applyFilter('duration', Minutes, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter easy recipes | applyFilter('easykeyword', _, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes on the exclusion of a specific ingredient | applyFilter('excludeingredient', Ingredient, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes on the exclusion of a specific ingredient type (ex. beeffor example: ‘beef’) | applyFilter('excludeingredienttype', Ingredient, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicates to filter recipes on a specific ingredient inclusion | applyFilter('ingredient', Ingredient, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter by including an ingredient type | applyFilter('ingredienttype', Ingredient, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes on meal type (breakfast e.g.for example: breakfast) | applyFilter('mealType', Value, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes on a maximum number of ingredients | applyFilter('nrOfIngredients', Value, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes on a maximum number of steps | applyFilter('nrSteps', Value, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes and return fast recipes. A recipe is fast if it takes less than 30 minutes | applyFilter('shorttimekeyword', _, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter on the number of servings | applyFilter('servings', Value, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes on tag ex. pizza is a tag a tag (for example: pizza) | applyFilter('tag', Value, RecipeIDsIn, RecipeIDsOut) :- |
|
Further Necessary Intents
deleteFilterValue
delete filter value is for when ‘deleteFilterValue’ is useful to deal with a scenario where the user requests to remove a filter that they have already put on specifically. For example, “I wish to remove the onion filter”, “Forget about excluding broccoli”, and “Can you delete the Chinese cuisine”.
It is thus important that in your training phrases you include a variety of entities and that these entities are also given specific values and parameter names in the Action and Parameters tables. Your entity table under Action and Parameters should thus look like this when you are done.
...
deleteParameter
The delete parameter ‘deleteParameter’ intent is identified when the user requests to remove a kind of constraint. For example, “I wish to remove the ingredient constraint”, and “Please drop the step constraint”. This intent requires the use of a certain entity, make . Make sure to include it in your action and parameters section.
noMoreFilters
No more filters The ‘noMoreFilters’ intent is used when the user does not want to add any more filters to their recipes list and wishes to see the available recipes.
recipeRequest
Recipe request ‘recipeRequest’ is used to confirm the user's choice of recipes . (“I want this specific recipe name here”). In entitiesUnder Entities, you can find an entity for the recipe names in our database.
...
In the end, your Intent page should look like this:
...
...
That’s the end of the basic implementation of the Natural Language Understanding of your agent. Make sure to properly test each intent, entity and rule that you have implemented (further detailed in the System testing section).