Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.
/ autochef Public archive

Commit d27cac8

Browse files
committed
Initial recipe commits
1 parent c4a0de6 commit d27cac8

6 files changed

+196
-22
lines changed

api/recipes/cucumber_salad.pl

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
% properties
2+
meal(cucumber_salad).
3+
serves(cucumber_salad, 1).
4+
difficulty(cucumber_salad, 1).
5+
6+
% tag(recipe, keyword).
7+
tag(cucumber_salad, vegan).
8+
tag(cucumber_salad, vegetarian).
9+
tag(cucumber_salad, salad).
10+
11+
% ingredient(recipe, ingredient, [unit, quantity]).
12+
ingredient(cucumber_salad, cucumber, [unit, 0.333]).
13+
ingredient(cucumber_salad, salt, [teaspoon, 0.5]).
14+
ingredient(cucumber_salad, pepper, [teaspoon, 0.5]).
15+
ingredient(cucumber_salad, seasoned_rice_vinegar, [tablespoon, 1]).
16+
17+
% step(recipe, output, [requirements], [[utensils]], [duration, quantity]).
18+
step(cucumber_salad, peeled_cucumber, [cucumber], [[vegetable_peeler]], [minutes, 1]).
19+
step(cucumber_salad, sliced_cucumber, [peeled_cucumber], [[knife]], [minutes, 1]).
20+
step(cucumber_salad, pressed_cucumber, [sliced_cucumber, salt], [[plate]], [minutes, 30]).
21+
step(cucumber_salad, sieved_cucumber, [pressed_cucumber, water], [[sieve, towel]], [minutes, 1]).
22+
step(cucumber_salad, cucumber_salad, [sieved_cucumber, seasoned_rice_vinegar, salt, pepper], [], [minutes, 1]).
23+
24+
% instructions(language, country, ingredient, text).
25+
instructions(en, _, peeled_cucumber, 'Peel the cucumber.').
26+
instructions(en, _, sliced_cucumber, 'Slice it into thin chunks, and put the slices onto a plate.').
27+
instructions(en, _, pressed_cucumber, 'Next, sprinkle salt over the slices and weigh another plate down on top of them, and leave for 30 minutes.').
28+
instructions(en, _, sieved_cucumber, 'Once ready, remove the slices and give them a sieve, and dry them out with a towel.').
29+
instructions(en, _, cucumber_salad, 'Finally, pour the rice vinegar over the top, and add the salt and papper.').
30+
31+
% title(language, country, ingredient, text).
32+
title(en, _, cucumber_salad, 'Healthy Cucumber Salad').
33+
34+
% extra(recipe, extra).
35+
extra(cucumber_salad, cottage_cheese).
36+
extra(cucumber_salad, tuna).
37+
extra(cucumber_salad, salmon).
38+
39+
% reusable(recipe, output, [lifetime, quantity]).
40+
reusable(cucumber_salad, sliced_cucumber, [days, 2]).
41+
reusable(cucumber_salad, cucumber_salad, [days, 2]).

api/recipes/moroccan_spice_mix.pl

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
% properties
2+
serves(moroccan_spice_mix, 1).
3+
difficulty(moroccan_spice_mix, 1).
4+
5+
% tag(recipe, keyword).
6+
tag(moroccan_spice_mix, vegan).
7+
tag(moroccan_spice_mix, vegetarian).
8+
tag(moroccan_spice_mix, moroccan).
9+
10+
% ingredient(recipe, ingredient, [unit, quantity]).
11+
ingredient(moroccan_spice_mix, cumin, [teaspoon, 2.5]).
12+
ingredient(moroccan_spice_mix, coriander, [teaspoon, 2]).
13+
ingredient(moroccan_spice_mix, turmeric, [teaspoon, 0.5]).
14+
ingredient(moroccan_spice_mix, paprika, [teaspoon, 0.5]).
15+
16+
% step(recipe, output, [requirements], [[utensils]], [duration, quantity]).
17+
step(moroccan_spice_mix, moroccan_spice_mix, [cumin, coriander, turmeric, paprika], [], [minutes, 1]).
18+
19+
% instructions(language, country, ingredient, text).
20+
instructions(en, _, sliced_tomato, 'Mix the spices together, and, if keeping the mix for some time, seal in a jar.').
21+
22+
% title(language, country, ingredient, text).
23+
title(en, _, moroccan_spice_mix, 'Tomato Salad').
24+
25+
% extra(recipe, extras).
26+
extra(moroccan_spice_mix, diced_onion).
27+
28+
% reusable(recipe, output).
29+
reusable(moroccan_spice_mix, moroccan_spice_mix, [months, 6]).

api/recipes/tomato_pasta.pl

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
% properties
2+
meal(tomato_pasta).
3+
serves(tomato_pasta, 2).
4+
difficulty(tomato_pasta, 2).
5+
6+
% tag(recipe, keyword).
7+
tag(tomato_pasta, vegan).
8+
tag(tomato_pasta, vegetarian).
9+
tag(tomato_pasta, italian).
10+
11+
% ingredient(recipe, ingredient, [unit, quantity]).
12+
ingredient(tomato_pasta, olive_oil, [tablespoon, 2]).
13+
ingredient(tomato_pasta, garlic, [clove, 1]).
14+
ingredient(tomato_pasta, tomato, [tin, 1]).
15+
ingredient(tomato_pasta, fresh_parsley, [tablespoon, 2]).
16+
17+
% step(recipe, output, [requirements], [[utensils]], [duration, quantity]).
18+
step(tomato_pasta, garlic_oil, [olive_oil, garlic], [[frying_pan]], [minutes, 3]).
19+
step(tomato_pasta, tomato_oil, [garlic_oil, tomato], [[wooden_spoon]], [minutes, 10]).
20+
step(tomato_pasta, cooked_pasta, [pasta, water], [[colander]], [minutes, 15]).
21+
step(tomato_pasta, tomato_pasta, [tomato_oil, cooked_pasta, parmesan], [], [minutes, 0]).
22+
23+
% instructions(language, country, ingredient, text).
24+
instructions(en, _, garlic_oil, 'Peel and crush the garlic cloves, and heat the oil in a frying pan. Once heated, add the garlic to the oil.').
25+
instructions(en, _, tomato_oil, 'Pour the tomatoes into the garlic oil, and use a spoon or other utensil to break the tomatoes down into a sauce. Leave to simmer for 10 minutes.').
26+
instructions(en, _, cooked_pasta, 'Bring enough water to cover the pasta to the boil, and then gradually add in the pasta itself. Keep on a low boil and taste after 10-15 minutes..').
27+
instructions(en, _, tomato_pasta, 'Pour the pasta onto plates for serving, and then spoon the tomato sauce over the top. Finally, add the grated cheese and/or pepper.').
28+
29+
% title(language, country, ingredient, text).
30+
title(en, _, tomato_oil, 'Tomato Sauce').
31+
title(en, _, cooked_pasta, 'Pasta').
32+
title(en, _, tomato_pasta, 'Pasta with Tomato Sauce').
33+
34+
% extra(recipe, extras).
35+
extra(tomato_pasta, grated_parmesan).
36+
extra(tomato_pasta, pepper).
37+
38+
% reusable(recipe, output).
39+
reusable(tomato_pasta, tomato_pasta, [months, 6]).

api/recipes/tomato_salad.pl

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
% properties
2+
meal(tomato_salad).
3+
serves(tomato_salad, 1).
4+
difficulty(tomato_salad, 1).
5+
6+
% tag(recipe, keyword).
7+
tag(tomato_salad, vegan).
8+
tag(tomato_salad, vegetarian).
9+
tag(tomato_salad, salad).
10+
11+
% ingredient(recipe, ingredient, [unit, quantity]).
12+
ingredient(tomato_salad, ripe_tomato, [unit, 3]).
13+
ingredient(tomato_salad, olive_oil, [tablespoon, 2]).
14+
ingredient(tomato_salad, salt, [teaspoon, 0.5]).
15+
ingredient(tomato_salad, pepper, [teaspoon, 0.5]).
16+
ingredient(tomato_salad, vinegar, [teaspoon, 2]).
17+
ingredient(tomato_salad, fresh_parsley, [tablespoon, 1]).
18+
19+
% step(recipe, output, [requirements], [[utensils]], [duration, quantity]).
20+
step(tomato_salad, sliced_tomato, [ripe_tomato], [[knife]], [minutes, 1]).
21+
step(tomato_salad, seasoned_tomato, [sliced_tomato, salt, pepper, olive_oil], [], [minutes, 15]).
22+
step(tomato_salad, tomato_salad, [seasoned_tomato, vinegar, fresh_parsley], [], [minutes, 1]).
23+
24+
% instructions(language, country, ingredient, text).
25+
instructions(en, _, sliced_tomato, 'Slice the tomatoes finely, and place them in a dish or bowl.').
26+
instructions(en, _, seasoned_tomato, 'Season the sliced tomatoes with salt and pepper, and dress with olive oil. Leave aside for 15 minutes.').
27+
instructions(en, _, tomato_salad, 'Take the seasoned tomatoes, and sprinkle them with the parsley and vinegar, and shake the resulting mix.').
28+
29+
% title(language, country, ingredient, text).
30+
title(en, _, tomato_salad, 'Tomato Salad').
31+
32+
% extra(recipe, extras).
33+
extra(tomato_salad, diced_onion).
34+
35+
% reusable(recipe, output).
36+
reusable(tomato_salad, tomato_salad, [days, 2]).

api/service.pl

+25-12
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,44 @@
1+
% Import libraries
12
:- use_module(library(http/thread_httpd)).
23
:- use_module(library(http/http_dispatch)).
34
:- use_module(library(http/http_parameters)).
45
:- use_module(library(http/http_json)).
56
:- use_module(library(http/json_convert)).
67
:- use_module(library(http/html_write)).
78

8-
% Load all ingredients and recipes
9-
:- multifile meal/1.
9+
% Up-front predicate declarations
1010
:- multifile product/1.
11-
:- multifile recipe/3.
11+
:- multifile meal/1.
12+
:- multifile serves/2.
13+
:- multifile difficulty/2.
14+
:- multifile tag/2.
15+
:- multifile ingredient/3.
16+
:- multifile step/5.
17+
:- multifile instructions/4.
18+
:- multifile title/4.
19+
:- multifile extra/2.
20+
:- multifile reusable/3.
21+
22+
:- dynamic stocked/3.
1223

24+
% Load rules database
1325
:- consult('ingredients/*').
26+
:- consult('nutrition/*').
27+
:- consult('utensils/*').
1428
:- consult('recipes/*').
1529
:- consult('rules').
1630

17-
:- http_handler(possibilities(.), list_possibilities, []).
31+
% Register HTTP endpoints
1832
http:location(possibilities, root(possibilities), []).
33+
http:location(instructions, root(instructions), []).
1934

35+
:- http_handler(possibilities(.), list_possibilities, []).
2036
:- http_handler(instructions(.), list_instructions, []).
21-
http:location(instructions, root(instructions), []).
2237

23-
:- dynamic stocked/3.
38+
% Start the HTTP server
39+
:- http_server(http_dispatch, [port(3475)]).
2440

25-
% Recipe suggestions handler
41+
% Handle user recipe suggestion
2642
list_possibilities(Request) :-
2743
http_parameters(Request, [], [form_data(Params)]),
2844
findall(_, (member(=(K,V), Params), assert(stocked(Request, K,V))), _),
@@ -31,7 +47,7 @@
3147
reply_html_page(_, [ table([ \rows(Possibilities) ]) ]),
3248
retractall(stocked(Request, _, _)).
3349

34-
% Recipe instructions handler
50+
% Handle recipe instruction listings
3551
list_instructions(Request) :-
3652
http_parameters(Request, [], [form_data(Params)]),
3753
findall(_, (member(=(K,V), Params), assert(stocked(Request, K,V))), _),
@@ -42,11 +58,8 @@
4258
reply_json(json([prerequisites=JSON]), [content_type='text/plain']),
4359
retractall(stocked(Request, _, _)).
4460

45-
% Render each recipe inside an HTML table row
61+
% Render a list as a set of HTML table rows
4662
rows([]) --> [].
4763
rows([H|T]) -->
4864
html(tr([td(H)])),
4965
rows(T).
50-
51-
% Start the server
52-
:- http_server(http_dispatch, [port(3475)]).

doc/interfaces

+26-10
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,49 @@ user recipe options
33
call api for possibilities
44

55
- input
6+
* user locale
67
* user ingredients
78
* user preferences
89

910
- output
1011
* recipes
11-
* recipe durations
12-
* recipe nutrition
13-
* recipe ingredient usage efficiency
12+
- identifier
13+
- title (localized)
14+
- duration
15+
- nutrition
16+
- efficiency score
1417

1518
user recipe display
1619
---
1720
all api for instructions
1821

1922
- input
23+
* user locale
2024
* user ingredients
2125
* user recipe
22-
* user servings
26+
* servings required
2327

2428
- output
2529
* prerequisite ingredients
26-
* prerequisite ingredient status (available / buy)
27-
* prerequisite ingredient quantities
30+
- identifier
31+
- status (available / buy)
32+
- quantity required
2833

2934
* recipe steps
30-
* recipe step start times
31-
* recipe step durations
32-
* recipe step dependencies (opt.)
35+
- title (localized)
36+
- instructions (localized)
37+
- dependencies
38+
- utensils
39+
- start time
40+
- duration
41+
42+
* utensils
43+
- identifier
44+
- name (localized)
45+
46+
* suggested extras
47+
- identifier
48+
- name (localized)
3349

3450
* summary nutrition
35-
* summray duration
51+
* summary duration

0 commit comments

Comments
 (0)