...
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 folder provided to you, and should be uploaded in Dialogflow by you.
Recipe Filtering Helper
...
Predicates
To filter the recipes for the user in the way they intend, their utterances are mapped onto the intents and entities you specified in Dialogflow. This then returns the identified intent (for example, ‘addFilter’) and entity information (for example, cuisine - ‘Chinese’). The MARBEL agent must be able to use this information. In order to make this happen, you need to create Prolog rules to filter the available recipes in the Prolog database. This can be done by introducing the following Prolog predicates. We have already specified the heads of all rules in the recipe_selection.pl
file. That is where you still need to add the bodies for these rules. We need a few helper functions before we can start implementing code for filtering, which are described next.
...
it can be made within 45 minutes,
it has less than 18 steps, and
it has less than 15 ingredients
Recipe Filtering
...
Predicate
You will now introduce a predicate applyFilter/4
for filtering recipes that returns a list of filtered recipes in the form of their RecipeIDs. The Again, the heads of the rules that you need to define are in the recipe_selection.pl
file.
There are a number of different variants rules that you need to implement of the ‘applyFilter’ rulefor the applyFilter/4
predicate, depending on the specific filter that needs to be applied - . For example, filtering recipes for a cuisine asks for a different function rule than filtering for the duration of a recipe. 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.
...
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 look like this when you are done.
...
deleteParameter
The ‘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 sure to include it in your action and parameters section.
...
In the end, your Intent page should look like this:
...
This marks You have reached the end of the basic implementation of the Natural Language Understanding of your and recipe filtering code for your recipe recommendation agent. Make sure to properly test each intent, entity and rule that you have implemented (further detailed in . For how to do this check out the Agent Testing section).