...
It is not necessary to add phrases that are completely unrelated to the topic of our recipe recommendation agent, as these would definitely come back as an unknown intent. Thus, what you should do is think of related phrases that would be close to an intent but should not match with it. For example, “I do not like mushrooms” is food related and refers to an ingredient entity ‘mushroom’. Yet, you might argue that it should not be matched to any of the intents you specify , because you do not want users to discuss their likes and dislikes with your agent. Alternatively, you could also argue to include ‘I like’ and ‘I dislike’ as training phrases for filtering by something. But that is a design decision for you to make! The Fallback Intent should be updated as you add more intents throughout the project.
...
Note |
---|
If the word you enter for an entity entry has synonyms, enter these as synonyms rather than adding these as different entity entries! |
...
timeKeyWord - words that refer to measurements of time (hour, minutes, etc.)
shortTimeKeyWord - for example ‘fast’, ‘quick’ etc.negationKeyword - to specify that something needs to be omitted (for example ‘without’ or ‘don’t’)
easyKeyWord - to specify recipes that are not hard to make (for example ‘simple’)
When you are done your Entities page should look as followshave the following entities:
...
The ‘addFilter’ Intent
The intent for filtering recipes is one of the most important intents. It is used to filter recipes for the user based on a variety of criteria. This is the first intent that employs all the entities we have created. In the user expressions, where the user is asking to filter, all different entities need to occur and be tagged in the set of examples. For example, for a training phrase like “I want a Chinese recipe”, ‘Chinese' needs to be tagged as ‘cuisine’, so this phrase can be parsed by Dialogflow in order to apply the filter ‘cuisine’ to the recipes in our database. The ‘addFilter’ intent can be found in the project provided to you to start with and should be uploaded in Dialogflow by you.
...
In the diet rule, we need to find all the ingredients that a certain recipe has and then input them into a new function we shall create below diet, called ‘ingredientsMeetDiet’. This function should return a diet should work if the list of ingredients that fit of the inputted RecipeID fits the dietary restriction . This list should be returned with the name inputted DietaryRestriction.
Code Block |
---|
ingredientsMeetDiet([ Ingredient | Rest ], DietaryRestriction) :- |
The ingredientsMeetDiet predicate is our stop clause, which should take a list of ingredients and check if each one meets a dietary restriction. It has a stop clause that is in the file already and 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.
...
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 (such 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 (for 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 (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 a tag (for example: pizza) | applyFilter('tag', Value, RecipeIDsIn, RecipeIDsOut) :- |
|
...