Table of Contents | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
Including ingredients, meal types, cuisines, dietary restrictions, short recipes, easy recipes.
Prolog and Patterns
We need to refine our logic now for retrieving only those recipes that satisfy specific filters. We already introduced a recipeFiltered/3
predicate for Request a Recommendation but there it did not have to do any serious work yet. We only introduced the base case without any filters (an empty list of filters) but now need to deal with the case where we have some filters that a user provided. The basic idea to define a recursive clause for recipeFiltered/3
is simple: apply the first filter in the list to the recipes and recursively filter the remaining recipes using the remaining filters. We provide you below with the recursive clause that you should add below the base clause that we added earlier in the recipe_selection.pl
file:
...
For the featureRemovalRequest
intent, you should add a simple text/2
fact. Use as response text, for example, "Can you have a look again and remove one of your recipe requirements?".
Visuals
We want to differentiate what we show to a user depending on the number of recipes that still meet the user’s requests. The basic idea is that we should not show a large number of recipes to a user but we can show recipe details when the number of remaining recipes becomes sufficiently small (we chose <16, see also above). As a consequence, we want to create two different versions of the a50recipeSelect
page that we created for Request a Recommendation : one that just shows the feature requests made when there are more than 15 recipes that meet these requests, and another for when there are less that 16 which shows the recipe details (titles and pictures) for all of the remaining recipes.
...
You should also add more information to this first a50recipeSelect
page. The main requirement is that the page shows all the user’s feature requests or filters. You can collect these from the agent’s memory.
...
Recipe Overview 2 page
A simple way to start writing some code for this page is to copy-paste the code you already have for the recipe recommendation page and modify it. Most importantly, you need to make sure this page is only shown if the number of filtered recipes is below or equal to 15 and if the user is still trying to select a recipe.
...
Your final page should look something like this (just an example, you should be able to easily improve!).
...
Extend the
...
Recipe Confirmation page
You should extend the initial version of the recipe confirmation page that we created for Request a Recommendation . The main requirement is that the page now also will show the recipe instructions, the ingredient list with quantities, the duration, and number of servings. Use the Prolog rules you created for steps(RecipeID, StepList)
and ingredients(RecipeID, IngredientList)
to retrieve the first two from the recipe database and the time/2
and servings/2
predicates for the last two. Add the duration and servings to the card that already was created for this page. Add two new https://www.w3schools.com/bootstrap4/bootstrap_cards.asp to the page for showing the recipe instructions and list of ingredients. You may also want to add the feature requests to the recipe confirmation page, but we leave this design choice up to you. You definitely may want to put more work in the styling of the content and the layout of this page to make it look appealing.
...