{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Manual Recipe Creation based on Popular Yummly Recipes"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"sys.path.append(\"../\")\n",
"sys.path.append(\"../EvolutionaryAlgorithm/\")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
" \n",
" "
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
" \n",
" "
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"../EvolutionaryAlgorithm/EvolutionaryAlgorithm.py:60: TqdmExperimentalWarning:\n",
"\n",
"Using `tqdm.autonotebook.tqdm` in notebook mode. Use `tqdm.tqdm` instead to force console mode (e.g. in jupyter console)\n",
"\n"
]
}
],
"source": [
"import EvolutionaryAlgorithm as EA"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"def ingredient_nodes(ing_list):\n",
" d = {}\n",
" for ing in ing_list:\n",
" d[ing] = EA.IngredientNode(ing)\n",
" return d"
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {},
"outputs": [],
"source": [
"def act(d, act, ing):\n",
" a = EA.ActionNode(act)\n",
" \n",
" p_a = d[ing]\n",
" \n",
" while p_a.parent() is not None:\n",
" p_a = p_a.parent()\n",
" \n",
" a.add_child(p_a)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"def mix(d, ing_a, ing_b):\n",
" p_a = d[ing_a]\n",
" p_b = d[ing_b]\n",
" \n",
" while p_a.parent() is not None:\n",
" p_a = p_a.parent()\n",
" while p_b.parent() is not None:\n",
" p_b = p_b.parent()\n",
" \n",
" m = EA.MixNode()\n",
" m.add_child(p_a)\n",
" m.add_child(p_b)\n",
" \n",
" "
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
"def get_root(d):\n",
" parents = set()\n",
" for n in d:\n",
" p = d[n]\n",
" while p.parent() is not None:\n",
" p = p.parent()\n",
" parents.add(p)\n",
" \n",
" pp = list(parents)\n",
" if len(pp) == 1:\n",
" pp[0].simplify()\n",
" return pp[0]\n",
" \n",
" m = EA.MixNode()\n",
" for p in pp:\n",
" m.add_child(p)\n",
" m.simplify()\n",
" return m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Easy Fried Rice\n",
"https://www.yummly.com/recipe/Easy-Fried-Rice-2306391#directions"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* Ingredients"
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * onion\n",
" * salt\n",
" * garlic clove\n",
" * oyster sauce\n",
" * egg\n",
" * soy sauce\n",
" * carrot\n",
" * rice\n",
" * sesame oil\n",
" * butter\n",
" * pea\n",
" * pepper\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | melt butter and mix it with pea, carrot and garlic clove. Then saute it. |\n",
"| 2 | slice onion, cook rice and mix it with soy sauce and oyster sauce and mix it together with the results of step 1. Then fry it. |\n",
"| 3 | whisk egg and mix it with sesame oil, salt and pepper and mix it together with the results of step 2. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# ingredients:\n",
"\n",
"d = ingredient_nodes([\n",
" \"butter\",\n",
" \"egg\",\n",
" \"pea\",\n",
" \"carrot\",\n",
" \"garlic clove\",\n",
" \"salt\",\n",
" \"pepper\",\n",
" \"rice\",\n",
" \"onion\",\n",
" \"soy sauce\",\n",
" \"oyster sauce\",\n",
" \"sesame oil\"\n",
"])\n",
"\n",
"# actions\n",
"\n",
"act(d, \"melt\", \"butter\")\n",
"act(d, \"whisk\", \"egg\")\n",
"act(d, \"cook\", \"rice\")\n",
"act(d, \"slice\", \"onion\")\n",
"mix(d, \"salt\", \"egg\")\n",
"mix(d, \"pepper\", \"egg\")\n",
"mix(d, \"butter\", \"garlic clove\")\n",
"mix (d, \"pea\", \"butter\")\n",
"mix (d, \"carrot\", \"butter\")\n",
"act(d, \"saute\", \"butter\")\n",
"mix (d, \"butter\", \"rice\")\n",
"mix (d, \"butter\", \"onion\")\n",
"mix (d, \"soy sauce\", \"butter\")\n",
"mix (d, \"oyster sauce\", \"butter\")\n",
"act(d, \"fry\", \"rice\")\n",
"\n",
"r = get_root(d)\n",
"\n",
"display(r.dot())\n",
"display(r.to_instruction().to_markdown())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Easy Lazy Day Lasagna\n",
"https://www.momontimeout.com/lazy-day-lasagna/?utm_campaign=yummly"
]
},
{
"cell_type": "code",
"execution_count": 55,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * pasta sauce\n",
" * noodle\n",
" * ricotta cheese\n",
" * mozzarella cheese\n",
" * water\n",
" * ground beef\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | brown ground beef and mix it with water. Then simmer it. |\n",
"| 2 | Mix noodle, mozzarella cheese, ricotta cheese and pasta sauce and mix it together with the results of step 1. Then bake it. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"\n",
"d = ingredient_nodes([\n",
" \"noodle\",\n",
" \"ground beef\",\n",
" \"pasta sauce\",\n",
" \"water\",\n",
" \"ricotta cheese\",\n",
" \"mozzarella cheese\"\n",
"])\n",
"\n",
"# actions\n",
"\n",
"mix (d, \"noodle\", \"pasta sauce\")\n",
"act(d, \"brown\", \"ground beef\")\n",
"mix (d, \"water\", \"ground beef\")\n",
"act(d, \"simmer\", \"ground beef\")\n",
"mix (d, \"noodle\", \"ricotta cheese\")\n",
"mix (d, \"noodle\", \"mozzarella cheese\")\n",
"mix (d, \"noodle\", \"ground beef\")\n",
"act(d, \"bake\", \"noodle\")\n",
"\n",
"r = get_root(d)\n",
"\n",
"display(r.dot())\n",
"display(r.to_instruction().to_markdown())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Firecracker Chicken\n",
"https://www.melskitchencafe.com/firecracker-chicken/?utm_campaign=yummly"
]
},
{
"cell_type": "code",
"execution_count": 127,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * hot sauce\n",
" * cornstach\n",
" * salt\n",
" * sugar\n",
" * canola oil\n",
" * cider vinegar\n",
" * egg\n",
" * rice\n",
" * water\n",
" * pepper\n",
" * chicken breast\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | beat and whisk egg |\n",
"| 2 | heat canola oil, cut chicken breast and mix it with cornstach, pepper and salt and mix it together with the results of step 1. Then cook it. |\n",
"| 3 | Mix hot sauce and sugar and mix it together with the results of step 2. Then bake it. |\n",
"| 4 | steam rice and mix it with water and cider vinegar and mix it together with the results of step 3. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"\n",
"d = ingredient_nodes([\n",
" \"hot sauce\",\n",
" \"sugar\",\n",
" \"water\",\n",
" \"cider vinegar\",\n",
" \"salt\",\n",
" \"canola oil\",\n",
" \"chicken breast\",\n",
" \"salt\",\n",
" \"pepper\",\n",
" \"cornstach\",\n",
" \"egg\",\n",
" \"rice\"\n",
" \n",
"])\n",
"\n",
"# actions\n",
"\n",
"act(d, \"beat\", \"egg\")\n",
"act(d, \"whisk\", \"egg\")\n",
"act(d, \"cut\", \"chicken breast\")\n",
"mix(d, \"chicken breast\", \"salt\")\n",
"mix(d, \"chicken breast\", \"pepper\")\n",
"mix(d, \"cornstach\", \"chicken breast\")\n",
"\n",
"mix(d, \"chicken breast\", \"egg\")\n",
"\n",
"act(d, \"heat\", \"canola oil\")\n",
"\n",
"mix(d, \"chicken breast\", \"canola oil\")\n",
"\n",
"act(d, \"cook\", \"chicken breast\")\n",
"\n",
"mix(d, \"sugar\", \"hot sauce\")\n",
"mix(d, \"hot sauce\", \"chicken breast\")\n",
"act(d, \"bake\", \"chicken breast\")\n",
"\n",
"act(d, \"steam\", \"rice\")\n",
"mix(d, \"chicken breast\", \"rice\")\n",
"\n",
"r = get_root(d)\n",
"\n",
"display(r.dot())\n",
"display(r.to_instruction().to_markdown())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Italian Drunken Noodles\n",
"https://www.yummly.com/recipe/Italian-Drunken-Noodles-1835835#directions"
]
},
{
"cell_type": "code",
"execution_count": 61,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * salt\n",
" * olive oil\n",
" * garlic clove\n",
" * tomato\n",
" * white wine\n",
" * egg noodle\n",
" * parsley\n",
" * sausage\n",
" * basil\n",
" * pepper\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | cook and drain egg noodle |\n",
"| 2 | dice pepper and mix it with salt. Then saute it. |\n",
"| 3 | Mix olive oil and sausage. Then heat it. |\n",
"| 4 | dice tomato and mix it with white wine and garlic clove and mix it together with the results of step 2 and step 3. Then simmer it. |\n",
"| 5 | Mix basil and parsley and mix it together with the results of step 1 and step 4. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"\n",
"d = ingredient_nodes([\n",
" \"sausage\",\n",
" \"salt\",\n",
" \"pepper\",\n",
" \"garlic clove\",\n",
" \"white wine\",\n",
" \"tomato\",\n",
" \"parsley\",\n",
" \"basil\",\n",
" \"egg noodle\",\n",
" \"olive oil\"\n",
"])\n",
"\n",
"# actions\n",
"\n",
"mix (d, \"olive oil\", \"sausage\")\n",
"act (d, \"heat\", \"sausage\")\n",
"act (d, \"dice\", \"pepper\")\n",
"mix (d, \"pepper\", \"salt\")\n",
"act (d, \"saute\", \"pepper\")\n",
"mix (d, \"pepper\", \"garlic clove\")\n",
"mix (d, \"white wine\", \"pepper\")\n",
"act (d, \"dice\", \"tomato\")\n",
"mix (d, \"tomato\", \"pepper\")\n",
"mix (d, \"sausage\", \"pepper\")\n",
"act (d, \"simmer\", \"sausage\")\n",
"mix (d, \"parsley\", \"pepper\")\n",
"mix (d, \"basil\", \"pepper\")\n",
"\n",
"act(d, \"cook\", \"egg noodle\")\n",
"act(d, \"drain\", \"egg noodle\")\n",
"\n",
"mix(d, \"egg noodle\", \"sausage\")\n",
"\n",
"r = get_root(d)\n",
"\n",
"display(r.dot())\n",
"display(r.to_instruction().to_markdown())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Italian Pasta Salad\n",
"https://www.yummly.com/recipe/Italian-Pasta-Salad-9104504#directions"
]
},
{
"cell_type": "code",
"execution_count": 66,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * dressing\n",
" * cheese\n",
" * salt\n",
" * tomato\n",
" * pasta\n",
" * black olive\n",
" * red onion\n",
" * cucumber\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | peel and chop cucumber |\n",
"| 2 | Mix pasta and salt. Then cook it. |\n",
"| 3 | drain the result of step 2 |\n",
"| 4 | dice red onion, slice black olive and mix it with dressing, cheese and tomato and mix it together with the results of step 1 and step 3. Then refrigerate it. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"\n",
"d = ingredient_nodes([\n",
" \"pasta\",\n",
" \"cucumber\",\n",
" \"tomato\",\n",
" \"cheese\",\n",
" \"black olive\",\n",
" \"red onion\",\n",
" \"dressing\",\n",
" \"salt\"\n",
"])\n",
"\n",
"# actions\n",
"\n",
"mix (d, \"salt\", \"pasta\")\n",
"act (d, \"peel\", \"cucumber\")\n",
"act (d, \"chop\", \"cucumber\")\n",
"act (d, \"slice\", \"black olive\")\n",
"act (d, \"dice\", \"red onion\")\n",
"act (d, \"cook\", \"pasta\")\n",
"act (d, \"drain\", \"pasta\")\n",
"mix (d, \"pasta\", \"cucumber\")\n",
"mix (d, \"pasta\", \"tomato\")\n",
"mix (d, \"pasta\", \"cheese\")\n",
"mix (d, \"pasta\", \"black olive\")\n",
"mix (d, \"pasta\", \"red onion\")\n",
"mix (d, \"pasta\", \"dressing\")\n",
"\n",
"act(d, \"refrigerate\", \"pasta\")\n",
"\n",
"r = get_root(d)\n",
"\n",
"display(r.dot())\n",
"display(r.to_instruction().to_markdown())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Mexican Rice\n",
"https://www.homesicktexan.com/2008/06/with-beans-comes-rice.html"
]
},
{
"cell_type": "code",
"execution_count": 77,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * onion\n",
" * olive oil\n",
" * garlic clove\n",
" * lime juice\n",
" * chicken broth\n",
" * salt\n",
" * cilantro\n",
" * tomato\n",
" * ground cumin\n",
" * rice\n",
" * butter\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | dice onion and mix it with garlic clove, tomato, olive oil and ground cumin. Then cook it. |\n",
"| 2 | Mix rice, butter and chicken broth. Then boil it. |\n",
"| 3 | chop cilantro and mix it with lime juice and salt and mix it together with the results of step 1 and step 2. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"\n",
"d = ingredient_nodes([\n",
" \"rice\",\n",
" \"chicken broth\",\n",
" \"butter\",\n",
" \"olive oil\",\n",
" \"onion\",\n",
" \"garlic clove\",\n",
" \"tomato\",\n",
" \"lime juice\",\n",
" \"cilantro\",\n",
" \"ground cumin\",\n",
" \"salt\"\n",
"])\n",
"\n",
"# actions\n",
"\n",
"act(d, \"dice\", \"onion\")\n",
"act(d, \"chop\", \"cilantro\")\n",
"\n",
"mix (d, \"rice\", \"chicken broth\")\n",
"mix (d, \"rice\", \"butter\")\n",
"act (d, \"boil\", \"rice\")\n",
"\n",
"mix (d, \"olive oil\", \"onion\")\n",
"mix (d, \"garlic clove\", \"onion\")\n",
"mix (d, \"tomato\", \"onion\")\n",
"mix (d, \"ground cumin\", \"onion\")\n",
"act (d, \"cook\", \"onion\")\n",
"\n",
"mix (d, \"rice\", \"onion\")\n",
"mix (d, \"lime juice\", \"onion\")\n",
"mix (d, \"cilantro\", \"onion\")\n",
"\n",
"\n",
"r = get_root(d)\n",
"\n",
"display(r.dot())\n",
"display(r.to_instruction().to_markdown())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## One Pot Cheesy Taco Pasta\n",
"http://www.motherthyme.com/2016/07/one-pot-cheesy-taco-pasta.html?utm_campaign=yummly"
]
},
{
"cell_type": "code",
"execution_count": 84,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * cilantro\n",
" * cheese\n",
" * salt\n",
" * black pepper\n",
" * tomato\n",
" * pasta\n",
" * tortilla chip\n",
" * salsa\n",
" * avocado\n",
" * water\n",
" * ground beef\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | Mix salt, black pepper and ground beef. Then cook it. |\n",
"| 2 | drain the result of step 1 |\n",
"| 3 | Mix water, salsa and pasta and mix it together with the results of step 2. Then boil it. |\n",
"| 4 | chop tomato, chop cilantro and mix it with tortilla chip, cheese and avocado and mix it together with the results of step 3. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"\n",
"d = ingredient_nodes([\n",
" \"ground beef\",\n",
" \"salt\",\n",
" \"black pepper\",\n",
" \"water\",\n",
" \"salsa\",\n",
" \"pasta\",\n",
" \"cheese\",\n",
" \"tomato\",\n",
" \"avocado\",\n",
" \"cilantro\",\n",
" \"tortilla chip\"\n",
"])\n",
"\n",
"# actions\n",
"\n",
"act (d, \"chop\", \"tomato\")\n",
"act (d, \"chop\", \"cilantro\")\n",
"\n",
"mix (d, \"ground beef\", \"salt\")\n",
"mix (d, \"ground beef\", \"black pepper\")\n",
"act (d, \"cook\", \"ground beef\")\n",
"act (d, \"drain\", \"ground beef\")\n",
"\n",
"mix (d, \"ground beef\", \"salsa\")\n",
"mix (d, \"ground beef\", \"water\")\n",
"mix (d, \"ground beef\", \"pasta\")\n",
"\n",
"act(d, \"boil\", \"pasta\")\n",
"\n",
"mix (d, \"cheese\", \"pasta\")\n",
"\n",
"\n",
"r = get_root(d)\n",
"\n",
"display(r.dot())\n",
"display(r.to_instruction().to_markdown())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Spanish Rice and Beans\n",
"https://www.yummly.com/recipe/Spanish-Rice-and-Beans-814#directions"
]
},
{
"cell_type": "code",
"execution_count": 90,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * garlic clove\n",
" * oil\n",
" * kidney bean\n",
" * white onion\n",
" * salsa\n",
" * vegetable broth\n",
" * rice\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | Mix rice and oil. Then heat it. |\n",
"| 2 | chop white onion and mix it with garlic clove and vegetable broth and mix it together with the results of step 1. Then cook it. |\n",
"| 3 | drain kidney bean and mix it with salsa and mix it together with the results of step 2. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"\n",
"d = ingredient_nodes([\n",
" \"oil\",\n",
" \"rice\",\n",
" \"white onion\",\n",
" \"garlic clove\",\n",
" \"vegetable broth\",\n",
" \"salsa\",\n",
" \"kidney bean\"\n",
"])\n",
"\n",
"# actions\n",
"act (d, \"drain\", \"kidney bean\")\n",
"act (d, \"chop\", \"white onion\")\n",
"\n",
"mix (d, \"rice\", \"oil\")\n",
"act(d, \"heat\", \"rice\")\n",
"\n",
"mix(d, \"rice\", \"white onion\")\n",
"mix (d, \"rice\", \"garlic clove\")\n",
"mix (d, \"rice\", \"garlic clove\")\n",
"\n",
"mix (d, \"vegetable broth\", \"rice\")\n",
"\n",
"act (d, \"cook\", \"rice\")\n",
"\n",
"r = get_root(d)\n",
"\n",
"display(r.dot())\n",
"display(r.to_instruction().to_markdown())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Vegan Curried Rice\n",
"https://www.yummly.com/recipe/Vegan-Curried-Rice-2319743#directions"
]
},
{
"cell_type": "code",
"execution_count": 104,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n",
"\n",
"\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * salt\n",
" * garlic clove\n",
" * ginger\n",
" * olive oil\n",
" * broccoli\n",
" * carrot\n",
" * rice\n",
" * spinach\n",
" * water\n",
" * pepper\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | chop carrot, chop spinach, chop broccoli and mix it with garlic clove, ginger, olive oil and water. Then fry it. |\n",
"| 2 | cook rice and mix it with pepper and salt and mix it together with the results of step 1. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"\n",
"d = ingredient_nodes([\n",
" \"olive oil\",\n",
" \"ginger\",\n",
" \"garlic clove\",\n",
" \"carrot\",\n",
" \"broccoli\",\n",
" \"salt\",\n",
" \"pepper\",\n",
" \"water\",\n",
" \"rice\",\n",
" \"spinach\"\n",
"])\n",
"\n",
"# actions\n",
"act(d, \"chop\", \"carrot\")\n",
"act(d, \"chop\", \"broccoli\")\n",
"act(d, \"cook\",\"rice\")\n",
"act(d, \"chop\", \"spinach\")\n",
"\n",
"mix(d, \"olive oil\", \"ginger\")\n",
"mix(d, \"olive oil\", \"garlic clove\")\n",
"mix(d, \"olive oil\", \"carrot\")\n",
"mix(d, \"olive oil\", \"broccoli\")\n",
"mix(d, \"olive oil\", \"water\")\n",
"mix(d, \"olive oil\", \"spinach\")\n",
"\n",
"act(d, \"fry\", \"olive oil\")\n",
"\n",
"r = get_root(d)\n",
"\n",
"display(r.dot())\n",
"display(r.to_instruction().to_markdown())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Vegetable Ramen Pad Thai\n",
"https://www.yummly.com/recipe/Vegetable-Ramen-Pad-Thai-2067502#directions"
]
},
{
"cell_type": "code",
"execution_count": 119,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"**Ingredients**:\n",
" * vegetable\n",
" * peanut butter\n",
" * vegetable oil\n",
" * sriacha sauce\n",
" * water\n",
" * ramen noodle\n",
" * teriyaki sauce\n",
"\n",
"\n",
"**Instructions**:\n",
"\n",
"| Step | Instruction |\n",
"| ----:|:----------- |\n",
"| 1 | Mix vegetable oil and vegetable. Then cook it. |\n",
"| 2 | heat water and mix it with ramen noodle. Then cook it. |\n",
"| 3 | drain the result of step 2 |\n",
"| 4 | Mix sriacha sauce, peanut butter and teriyaki sauce and mix it together with the results of step 1 and step 3. |\n"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"\n",
"d = ingredient_nodes([\n",
" \"ramen noodle\",\n",
" \"vegetable oil\",\n",
" \"vegetable\",\n",
" \"teriyaki sauce\",\n",
" \"water\",\n",
" \"peanut butter\",\n",
" \"sriacha sauce\"\n",
"])\n",
"\n",
"# actions\n",
"act(d, \"heat\", \"water\")\n",
"mix(d, \"ramen noodle\", \"water\")\n",
"act(d, \"cook\", \"ramen noodle\")\n",
"act(d, \"drain\", \"ramen noodle\")\n",
"\n",
"mix (d, \"vegetable oil\", \"vegetable\")\n",
"act(d, \"cook\", \"vegetable\")\n",
"\n",
"mix (d, \"vegetable\", \"ramen noodle\")\n",
"\n",
"\n",
"r = get_root(d)\n",
"\n",
"#display(r.dot()) # ← cannot plot tree because some ingredients are unknown!\n",
"display(r.to_instruction().to_markdown())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}