{ "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", "\n", "%3\n", "\n", "\n", "\n", "260\n", "\n", " \n", "mix\n", "node score: 0.8947\n", "\n", "\n", "\n", "246\n", "\n", " \n", "whisk\n", "node score: 1.0000\n", "\n", "\n", "\n", "260->246\n", "\n", "\n", "\n", "\n", "\n", "244\n", "\n", " \n", "sesame oil\n", "node score:0.6667\n", "\n", "\n", "\n", "260->244\n", "\n", "\n", "\n", "\n", "\n", "259\n", "\n", " \n", "fry\n", "node score: 0.3750\n", "\n", "\n", "\n", "260->259\n", "\n", "\n", "\n", "\n", "\n", "238\n", "\n", " \n", "salt\n", "node score:0.6667\n", "\n", "\n", "\n", "260->238\n", "\n", "\n", "\n", "\n", "\n", "239\n", "\n", " \n", "pepper\n", "node score:0.6667\n", "\n", "\n", "\n", "260->239\n", "\n", "\n", "\n", "\n", "\n", "234\n", "\n", " \n", "egg\n", "node score:0.6667\n", "\n", "\n", "\n", "246->234\n", "\n", "\n", "\n", "\n", "\n", "258\n", "\n", " \n", "mix\n", "node score: 0.9545\n", "\n", "\n", "\n", "259->258\n", "\n", "\n", "\n", "\n", "\n", "254\n", "\n", " \n", "saute\n", "node score: 1.0000\n", "\n", "\n", "\n", "258->254\n", "\n", "\n", "\n", "\n", "\n", "242\n", "\n", " \n", "soy sauce\n", "node score:1.0000\n", "\n", "\n", "\n", "258->242\n", "\n", "\n", "\n", "\n", "\n", "243\n", "\n", " \n", "oyster sauce\n", "node score:1.0000\n", "\n", "\n", "\n", "258->243\n", "\n", "\n", "\n", "\n", "\n", "248\n", "\n", " \n", "slice\n", "node score: 1.0000\n", "\n", "\n", "\n", "258->248\n", "\n", "\n", "\n", "\n", "\n", "247\n", "\n", " \n", "cook\n", "node score: 1.0000\n", "\n", "\n", "\n", "258->247\n", "\n", "\n", "\n", "\n", "\n", "253\n", "\n", " \n", "mix\n", "node score: 1.0000\n", "\n", "\n", "\n", "254->253\n", "\n", "\n", "\n", "\n", "\n", "245\n", "\n", " \n", "melt\n", "node score: 1.0000\n", "\n", "\n", "\n", "253->245\n", "\n", "\n", "\n", "\n", "\n", "235\n", "\n", " \n", "pea\n", "node score:0.8333\n", "\n", "\n", "\n", "253->235\n", "\n", "\n", "\n", "\n", "\n", "236\n", "\n", " \n", "carrot\n", "node score:0.5000\n", "\n", "\n", "\n", "253->236\n", "\n", "\n", "\n", "\n", "\n", "237\n", "\n", " \n", "garlic clove\n", "node score:0.5000\n", "\n", "\n", "\n", "253->237\n", "\n", "\n", "\n", "\n", "\n", "233\n", "\n", " \n", "butter\n", "node score:0.7778\n", "\n", "\n", "\n", "245->233\n", "\n", "\n", "\n", "\n", "\n", "241\n", "\n", " \n", "onion\n", "node score:1.0000\n", "\n", "\n", "\n", "248->241\n", "\n", "\n", "\n", "\n", "\n", "240\n", "\n", " \n", "rice\n", "node score:0.8333\n", "\n", "\n", "\n", "247->240\n", "\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", "\n", "%3\n", "\n", "\n", "\n", "274\n", "\n", " \n", "bake\n", "node score: 1.0000\n", "\n", "\n", "\n", "273\n", "\n", " \n", "mix\n", "node score: 0.9286\n", "\n", "\n", "\n", "274->273\n", "\n", "\n", "\n", "\n", "\n", "261\n", "\n", " \n", "noodle\n", "node score:1.0000\n", "\n", "\n", "\n", "273->261\n", "\n", "\n", "\n", "\n", "\n", "266\n", "\n", " \n", "mozzarella cheese\n", "node score:1.0000\n", "\n", "\n", "\n", "273->266\n", "\n", "\n", "\n", "\n", "\n", "270\n", "\n", " \n", "simmer\n", "node score: 1.0000\n", "\n", "\n", "\n", "273->270\n", "\n", "\n", "\n", "\n", "\n", "265\n", "\n", " \n", "ricotta cheese\n", "node score:1.0000\n", "\n", "\n", "\n", "273->265\n", "\n", "\n", "\n", "\n", "\n", "263\n", "\n", " \n", "pasta sauce\n", "node score:1.0000\n", "\n", "\n", "\n", "273->263\n", "\n", "\n", "\n", "\n", "\n", "269\n", "\n", " \n", "mix\n", "node score: 1.0000\n", "\n", "\n", "\n", "270->269\n", "\n", "\n", "\n", "\n", "\n", "264\n", "\n", " \n", "water\n", "node score:0.8333\n", "\n", "\n", "\n", "269->264\n", "\n", "\n", "\n", "\n", "\n", "268\n", "\n", " \n", "brown\n", "node score: 1.0000\n", "\n", "\n", "\n", "269->268\n", "\n", "\n", "\n", "\n", "\n", "262\n", "\n", " \n", "ground beef\n", "node score:0.7778\n", "\n", "\n", "\n", "268->262\n", "\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", "\n", "%3\n", "\n", "\n", "\n", "654\n", "\n", " \n", "mix\n", "node score: 0.7778\n", "\n", "\n", "\n", "629\n", "\n", " \n", "water\n", "node score:0.6667\n", "\n", "\n", "\n", "654->629\n", "\n", "\n", "\n", "\n", "\n", "651\n", "\n", " \n", "bake\n", "node score: 0.5000\n", "\n", "\n", "\n", "654->651\n", "\n", "\n", "\n", "\n", "\n", "652\n", "\n", " \n", "steam\n", "node score: 1.0000\n", "\n", "\n", "\n", "654->652\n", "\n", "\n", "\n", "\n", "\n", "630\n", "\n", " \n", "cider vinegar\n", "node score:0.6667\n", "\n", "\n", "\n", "654->630\n", "\n", "\n", "\n", "\n", "\n", "650\n", "\n", " \n", "mix\n", "node score: 0.6923\n", "\n", "\n", "\n", "651->650\n", "\n", "\n", "\n", "\n", "\n", "648\n", "\n", " \n", "cook\n", "node score: 0.6667\n", "\n", "\n", "\n", "650->648\n", "\n", "\n", "\n", "\n", "\n", "627\n", "\n", " \n", "hot sauce\n", "node score:1.0000\n", "\n", "\n", "\n", "650->627\n", "\n", "\n", "\n", "\n", "\n", "628\n", "\n", " \n", "sugar\n", "node score:1.0000\n", "\n", "\n", "\n", "650->628\n", "\n", "\n", "\n", "\n", "\n", "647\n", "\n", " \n", "mix\n", "node score: 0.7333\n", "\n", "\n", "\n", "648->647\n", "\n", "\n", "\n", "\n", "\n", "636\n", "\n", " \n", "cornstach\n", "node score:0.8333\n", "\n", "\n", "\n", "647->636\n", "\n", "\n", "\n", "\n", "\n", "646\n", "\n", " \n", "heat\n", "node score: 1.0000\n", "\n", "\n", "\n", "647->646\n", "\n", "\n", "\n", "\n", "\n", "641\n", "\n", " \n", "cut\n", "node score: 1.0000\n", "\n", "\n", "\n", "647->641\n", "\n", "\n", "\n", "\n", "\n", "635\n", "\n", " \n", "pepper\n", "node score:0.8333\n", "\n", "\n", "\n", "647->635\n", "\n", "\n", "\n", "\n", "\n", "634\n", "\n", " \n", "salt\n", "node score:0.8333\n", "\n", "\n", "\n", "647->634\n", "\n", "\n", "\n", "\n", "\n", "640\n", "\n", " \n", "whisk\n", "node score: 1.0000\n", "\n", "\n", "\n", "647->640\n", "\n", "\n", "\n", "\n", "\n", "632\n", "\n", " \n", "canola oil\n", "node score:0.7778\n", "\n", "\n", "\n", "646->632\n", "\n", "\n", "\n", "\n", "\n", "633\n", "\n", " \n", "chicken breast\n", "node score:0.8889\n", "\n", "\n", "\n", "641->633\n", "\n", "\n", "\n", "\n", "\n", "639\n", "\n", " \n", "beat\n", "node score: 1.0000\n", "\n", "\n", "\n", "640->639\n", "\n", "\n", "\n", "\n", "\n", "637\n", "\n", " \n", "egg\n", "node score:0.5833\n", "\n", "\n", "\n", "639->637\n", "\n", "\n", "\n", "\n", "\n", "638\n", "\n", " \n", "rice\n", "node score:1.0000\n", "\n", "\n", "\n", "652->638\n", "\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", "\n", "%3\n", "\n", "\n", "\n", "300\n", "\n", " \n", "mix\n", "node score: 0.6667\n", "\n", "\n", "\n", "299\n", "\n", " \n", "drain\n", "node score: 1.0000\n", "\n", "\n", "\n", "300->299\n", "\n", "\n", "\n", "\n", "\n", "282\n", "\n", " \n", "basil\n", "node score:0.6667\n", "\n", "\n", "\n", "300->282\n", "\n", "\n", "\n", "\n", "\n", "281\n", "\n", " \n", "parsley\n", "node score:0.6667\n", "\n", "\n", "\n", "300->281\n", "\n", "\n", "\n", "\n", "\n", "295\n", "\n", " \n", "simmer\n", "node score: 0.8571\n", "\n", "\n", "\n", "300->295\n", "\n", "\n", "\n", "\n", "\n", "298\n", "\n", " \n", "cook\n", "node score: 1.0000\n", "\n", "\n", "\n", "299->298\n", "\n", "\n", "\n", "\n", "\n", "283\n", "\n", " \n", "egg noodle\n", "node score:1.0000\n", "\n", "\n", "\n", "298->283\n", "\n", "\n", "\n", "\n", "\n", "294\n", "\n", " \n", "mix\n", "node score: 0.8947\n", "\n", "\n", "\n", "295->294\n", "\n", "\n", "\n", "\n", "\n", "279\n", "\n", " \n", "white wine\n", "node score:1.0000\n", "\n", "\n", "\n", "294->279\n", "\n", "\n", "\n", "\n", "\n", "289\n", "\n", " \n", "saute\n", "node score: 1.0000\n", "\n", "\n", "\n", "294->289\n", "\n", "\n", "\n", "\n", "\n", "292\n", "\n", " \n", "dice\n", "node score: 1.0000\n", "\n", "\n", "\n", "294->292\n", "\n", "\n", "\n", "\n", "\n", "286\n", "\n", " \n", "heat\n", "node score: 1.0000\n", "\n", "\n", "\n", "294->286\n", "\n", "\n", "\n", "\n", "\n", "278\n", "\n", " \n", "garlic clove\n", "node score:0.6667\n", "\n", "\n", "\n", "294->278\n", "\n", "\n", "\n", "\n", "\n", "288\n", "\n", " \n", "mix\n", "node score: 1.0000\n", "\n", "\n", "\n", "289->288\n", "\n", "\n", "\n", "\n", "\n", "287\n", "\n", " \n", "dice\n", "node score: 1.0000\n", "\n", "\n", "\n", "288->287\n", "\n", "\n", "\n", "\n", "\n", "276\n", "\n", " \n", "salt\n", "node score:0.8333\n", "\n", "\n", "\n", "288->276\n", "\n", "\n", "\n", "\n", "\n", "277\n", "\n", " \n", "pepper\n", "node score:0.8889\n", "\n", "\n", "\n", "287->277\n", "\n", "\n", "\n", "\n", "\n", "280\n", "\n", " \n", "tomato\n", "node score:1.0000\n", "\n", "\n", "\n", "292->280\n", "\n", "\n", "\n", "\n", "\n", "285\n", "\n", " \n", "mix\n", "node score: 1.0000\n", "\n", "\n", "\n", "286->285\n", "\n", "\n", "\n", "\n", "\n", "284\n", "\n", " \n", "olive oil\n", "node score:0.8333\n", "\n", "\n", "\n", "285->284\n", "\n", "\n", "\n", "\n", "\n", "275\n", "\n", " \n", "sausage\n", "node score:0.8333\n", "\n", "\n", "\n", "285->275\n", "\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", "\n", "%3\n", "\n", "\n", "\n", "343\n", "\n", " \n", "refrigerate\n", "node score: 0.7500\n", "\n", "\n", "\n", "342\n", "\n", " \n", "mix\n", "node score: 0.9630\n", "\n", "\n", "\n", "343->342\n", "\n", "\n", "\n", "\n", "\n", "328\n", "\n", " \n", "dressing\n", "node score:1.0000\n", "\n", "\n", "\n", "342->328\n", "\n", "\n", "\n", "\n", "\n", "334\n", "\n", " \n", "dice\n", "node score: 1.0000\n", "\n", "\n", "\n", "342->334\n", "\n", "\n", "\n", "\n", "\n", "325\n", "\n", " \n", "cheese\n", "node score:1.0000\n", "\n", "\n", "\n", "342->325\n", "\n", "\n", "\n", "\n", "\n", "332\n", "\n", " \n", "chop\n", "node score: 1.0000\n", "\n", "\n", "\n", "342->332\n", "\n", "\n", "\n", "\n", "\n", "336\n", "\n", " \n", "drain\n", "node score: 1.0000\n", "\n", "\n", "\n", "342->336\n", "\n", "\n", "\n", "\n", "\n", "324\n", "\n", " \n", "tomato\n", "node score:0.6667\n", "\n", "\n", "\n", "342->324\n", "\n", "\n", "\n", "\n", "\n", "333\n", "\n", " \n", "slice\n", "node score: 1.0000\n", "\n", "\n", "\n", "342->333\n", "\n", "\n", "\n", "\n", "\n", "327\n", "\n", " \n", "red onion\n", "node score:1.0000\n", "\n", "\n", "\n", "334->327\n", "\n", "\n", "\n", "\n", "\n", "331\n", "\n", " \n", "peel\n", "node score: 1.0000\n", "\n", "\n", "\n", "332->331\n", "\n", "\n", "\n", "\n", "\n", "323\n", "\n", " \n", "cucumber\n", "node score:0.8889\n", "\n", "\n", "\n", "331->323\n", "\n", "\n", "\n", "\n", "\n", "335\n", "\n", " \n", "cook\n", "node score: 1.0000\n", "\n", "\n", "\n", "336->335\n", "\n", "\n", "\n", "\n", "\n", "330\n", "\n", " \n", "mix\n", "node score: 1.0000\n", "\n", "\n", "\n", "335->330\n", "\n", "\n", "\n", "\n", "\n", "322\n", "\n", " \n", "pasta\n", "node score:1.0000\n", "\n", "\n", "\n", "330->322\n", "\n", "\n", "\n", "\n", "\n", "329\n", "\n", " \n", "salt\n", "node score:1.0000\n", "\n", "\n", "\n", "330->329\n", "\n", "\n", "\n", "\n", "\n", "326\n", "\n", " \n", "black olive\n", "node score:1.0000\n", "\n", "\n", "\n", "333->326\n", "\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", "\n", "%3\n", "\n", "\n", "\n", "392\n", "\n", " \n", "mix\n", "node score: 0.9762\n", "\n", "\n", "\n", "388\n", "\n", " \n", "cook\n", "node score: 1.0000\n", "\n", "\n", "\n", "392->388\n", "\n", "\n", "\n", "\n", "\n", "375\n", "\n", " \n", "lime juice\n", "node score:1.0000\n", "\n", "\n", "\n", "392->375\n", "\n", "\n", "\n", "\n", "\n", "383\n", "\n", " \n", "boil\n", "node score: 1.0000\n", "\n", "\n", "\n", "392->383\n", "\n", "\n", "\n", "\n", "\n", "378\n", "\n", " \n", "salt\n", "node score:0.6667\n", "\n", "\n", "\n", "392->378\n", "\n", "\n", "\n", "\n", "\n", "380\n", "\n", " \n", "chop\n", "node score: 1.0000\n", "\n", "\n", "\n", "392->380\n", "\n", "\n", "\n", "\n", "\n", "387\n", "\n", " \n", "mix\n", "node score: 1.0000\n", "\n", "\n", "\n", "388->387\n", "\n", "\n", "\n", "\n", "\n", "373\n", "\n", " \n", "garlic clove\n", "node score:0.6667\n", "\n", "\n", "\n", "387->373\n", "\n", "\n", "\n", "\n", "\n", "374\n", "\n", " \n", "tomato\n", "node score:0.6667\n", "\n", "\n", "\n", "387->374\n", "\n", "\n", "\n", "\n", "\n", "371\n", "\n", " \n", "olive oil\n", "node score:1.0000\n", "\n", "\n", "\n", "387->371\n", "\n", "\n", "\n", "\n", "\n", "379\n", "\n", " \n", "dice\n", "node score: 1.0000\n", "\n", "\n", "\n", "387->379\n", "\n", "\n", "\n", "\n", "\n", "377\n", "\n", " \n", "ground cumin\n", "node score:1.0000\n", "\n", "\n", "\n", "387->377\n", "\n", "\n", "\n", "\n", "\n", "372\n", "\n", " \n", "onion\n", "node score:1.0000\n", "\n", "\n", "\n", "379->372\n", "\n", "\n", "\n", "\n", "\n", "382\n", "\n", " \n", "mix\n", "node score: 1.0000\n", "\n", "\n", "\n", "383->382\n", "\n", "\n", "\n", "\n", "\n", "368\n", "\n", " \n", "rice\n", "node score:1.0000\n", "\n", "\n", "\n", "382->368\n", "\n", "\n", "\n", "\n", "\n", "370\n", "\n", " \n", "butter\n", "node score:1.0000\n", "\n", "\n", "\n", "382->370\n", "\n", "\n", "\n", "\n", "\n", "369\n", "\n", " \n", "chicken broth\n", "node score:1.0000\n", "\n", "\n", "\n", "382->369\n", "\n", "\n", "\n", "\n", "\n", "376\n", "\n", " \n", "cilantro\n", "node score:1.0000\n", "\n", "\n", "\n", "380->376\n", "\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", "\n", "%3\n", "\n", "\n", "\n", "415\n", "\n", " \n", "mix\n", "node score: 0.7500\n", "\n", "\n", "\n", "403\n", "\n", " \n", "tortilla chip\n", "node score:0.6667\n", "\n", "\n", "\n", "415->403\n", "\n", "\n", "\n", "\n", "\n", "404\n", "\n", " \n", "chop\n", "node score: 1.0000\n", "\n", "\n", "\n", "415->404\n", "\n", "\n", "\n", "\n", "\n", "399\n", "\n", " \n", "cheese\n", "node score:1.0000\n", "\n", "\n", "\n", "415->399\n", "\n", "\n", "\n", "\n", "\n", "413\n", "\n", " \n", "boil\n", "node score: 0.8333\n", "\n", "\n", "\n", "415->413\n", "\n", "\n", "\n", "\n", "\n", "401\n", "\n", " \n", "avocado\n", "node score:0.6667\n", "\n", "\n", "\n", "415->401\n", "\n", "\n", "\n", "\n", "\n", "405\n", "\n", " \n", "chop\n", "node score: 1.0000\n", "\n", "\n", "\n", "415->405\n", "\n", "\n", "\n", "\n", "\n", "400\n", "\n", " \n", "tomato\n", "node score:1.0000\n", "\n", "\n", "\n", "404->400\n", "\n", "\n", "\n", "\n", "\n", "412\n", "\n", " \n", "mix\n", "node score: 0.7500\n", "\n", "\n", "\n", "413->412\n", "\n", "\n", "\n", "\n", "\n", "396\n", "\n", " \n", "water\n", "node score:1.0000\n", "\n", "\n", "\n", "412->396\n", "\n", "\n", "\n", "\n", "\n", "397\n", "\n", " \n", "salsa\n", "node score:1.0000\n", "\n", "\n", "\n", "412->397\n", "\n", "\n", "\n", "\n", "\n", "409\n", "\n", " \n", "drain\n", "node score: 1.0000\n", "\n", "\n", "\n", "412->409\n", "\n", "\n", "\n", "\n", "\n", "398\n", "\n", " \n", "pasta\n", "node score:1.0000\n", "\n", "\n", "\n", "412->398\n", "\n", "\n", "\n", "\n", "\n", "408\n", "\n", " \n", "cook\n", "node score: 1.0000\n", "\n", "\n", "\n", "409->408\n", "\n", "\n", "\n", "\n", "\n", "407\n", "\n", " \n", "mix\n", "node score: 1.0000\n", "\n", "\n", "\n", "408->407\n", "\n", "\n", "\n", "\n", "\n", "394\n", "\n", " \n", "salt\n", "node score:0.8889\n", "\n", "\n", "\n", "407->394\n", "\n", "\n", "\n", "\n", "\n", "395\n", "\n", " \n", "black pepper\n", "node score:0.8889\n", "\n", "\n", "\n", "407->395\n", "\n", "\n", "\n", "\n", "\n", "393\n", "\n", " \n", "ground beef\n", "node score:0.8889\n", "\n", "\n", "\n", "407->393\n", "\n", "\n", "\n", "\n", "\n", "402\n", "\n", " \n", "cilantro\n", "node score:1.0000\n", "\n", "\n", "\n", "405->402\n", "\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", "\n", "%3\n", "\n", "\n", "\n", "441\n", "\n", " \n", "mix\n", "node score: 0.6364\n", "\n", "\n", "\n", "432\n", "\n", " \n", "drain\n", "node score: 1.0000\n", "\n", "\n", "\n", "441->432\n", "\n", "\n", "\n", "\n", "\n", "440\n", "\n", " \n", "cook\n", "node score: 1.0000\n", "\n", "\n", "\n", "441->440\n", "\n", "\n", "\n", "\n", "\n", "430\n", "\n", " \n", "salsa\n", "node score:0.6667\n", "\n", "\n", "\n", "441->430\n", "\n", "\n", "\n", "\n", "\n", "431\n", "\n", " \n", "kidney bean\n", "node score:0.3333\n", "\n", "\n", "\n", "432->431\n", "\n", "\n", "\n", "\n", "\n", "439\n", "\n", " \n", "mix\n", "node score: 0.5556\n", "\n", "\n", "\n", "440->439\n", "\n", "\n", "\n", "\n", "\n", "428\n", "\n", " \n", "garlic clove\n", "node score:0.6667\n", "\n", "\n", "\n", "439->428\n", "\n", "\n", "\n", "\n", "\n", "433\n", "\n", " \n", "chop\n", "node score: 0.0000\n", "\n", "\n", "\n", "439->433\n", "\n", "\n", "\n", "\n", "\n", "435\n", "\n", " \n", "heat\n", "node score: 1.0000\n", "\n", "\n", "\n", "439->435\n", "\n", "\n", "\n", "\n", "\n", "429\n", "\n", " \n", "vegetable broth\n", "node score:1.0000\n", "\n", "\n", "\n", "439->429\n", "\n", "\n", "\n", "\n", "\n", "427\n", "\n", " \n", "white onion\n", "node score:1.0000\n", "\n", "\n", "\n", "433->427\n", "\n", "\n", "\n", "\n", "\n", "434\n", "\n", " \n", "mix\n", "node score: 1.0000\n", "\n", "\n", "\n", "435->434\n", "\n", "\n", "\n", "\n", "\n", "426\n", "\n", " \n", "rice\n", "node score:0.8333\n", "\n", "\n", "\n", "434->426\n", "\n", "\n", "\n", "\n", "\n", "425\n", "\n", " \n", "oil\n", "node score:0.8333\n", "\n", "\n", "\n", "434->425\n", "\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", "\n", "%3\n", "\n", "\n", "\n", "502\n", "\n", " \n", "mix\n", "node score: 0.9167\n", "\n", "\n", "\n", "487\n", "\n", " \n", "pepper\n", "node score:0.6667\n", "\n", "\n", "\n", "502->487\n", "\n", "\n", "\n", "\n", "\n", "493\n", "\n", " \n", "cook\n", "node score: 1.0000\n", "\n", "\n", "\n", "502->493\n", "\n", "\n", "\n", "\n", "\n", "486\n", "\n", " \n", "salt\n", "node score:0.6667\n", "\n", "\n", "\n", "502->486\n", "\n", "\n", "\n", "\n", "\n", "501\n", "\n", " \n", "fry\n", "node score: 0.7143\n", "\n", "\n", "\n", "502->501\n", "\n", "\n", "\n", "\n", "\n", "489\n", "\n", " \n", "rice\n", "node score:1.0000\n", "\n", "\n", "\n", "493->489\n", "\n", "\n", "\n", "\n", "\n", "500\n", "\n", " \n", "mix\n", "node score: 0.9048\n", "\n", "\n", "\n", "501->500\n", "\n", "\n", "\n", "\n", "\n", "491\n", "\n", " \n", "chop\n", "node score: 1.0000\n", "\n", "\n", "\n", "500->491\n", "\n", "\n", "\n", "\n", "\n", "494\n", "\n", " \n", "chop\n", "node score: 1.0000\n", "\n", "\n", "\n", "500->494\n", "\n", "\n", "\n", "\n", "\n", "483\n", "\n", " \n", "garlic clove\n", "node score:0.6667\n", "\n", "\n", "\n", "500->483\n", "\n", "\n", "\n", "\n", "\n", "492\n", "\n", " \n", "chop\n", "node score: 1.0000\n", "\n", "\n", "\n", "500->492\n", "\n", "\n", "\n", "\n", "\n", "482\n", "\n", " \n", "ginger\n", "node score:1.0000\n", "\n", "\n", "\n", "500->482\n", "\n", "\n", "\n", "\n", "\n", "481\n", "\n", " \n", "olive oil\n", "node score:1.0000\n", "\n", "\n", "\n", "500->481\n", "\n", "\n", "\n", "\n", "\n", "488\n", "\n", " \n", "water\n", "node score:1.0000\n", "\n", "\n", "\n", "500->488\n", "\n", "\n", "\n", "\n", "\n", "484\n", "\n", " \n", "carrot\n", "node score:1.0000\n", "\n", "\n", "\n", "491->484\n", "\n", "\n", "\n", "\n", "\n", "490\n", "\n", " \n", "spinach\n", "node score:1.0000\n", "\n", "\n", "\n", "494->490\n", "\n", "\n", "\n", "\n", "\n", "485\n", "\n", " \n", "broccoli\n", "node score:1.0000\n", "\n", "\n", "\n", "492->485\n", "\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 }