CrockBot: Conversational Recipe Parser

For a natural language processing class, I worked with a team of other students to implement CrockBot, a command line conversational interface, in Python, for understanding, changing, and asking questions about recipes. The code would scrape information from Allrecipes.com, and get information like the ingredients and steps in the recipe. At any point, the user could ask a question, which CrockBot would attempt to Google the answer to. Unfortunately, Allrecipes has since changed the layout on their website and made CrockBot unusable. This was also made before language models like GPT existed, and if made now CrockBot would certainly incorporate text generation models. Nevertheless, the code for CrockBot can be found here: https://github.com/MJKIM700/Conversational-Interface

Conversational Interface

Unlike the advanced language models of the past few years, conversation was mostly hard-coded in. Conversation was handled via a listener that awaited user input in the command line. We made a list of things a user might say, with questions and commands like “how do i…” or “make this recipe healthier”. Anything unexpected would prompt the user to try again. Responses to these questions were hard coded as strings but the information relayed was determined dynamically.

Web Scraping

We used BeautifulSoup for web scraping. CrockBot would take an Allrecipes URL, then search through the source of the web page to get the recipe title, the list of ingredients, and the list of steps. When the user asked a question, such as “How do I preheat an oven”, CrockBot would reformat this question as a Google search link like "https://www.google.com/search?q=how+to+preheat+oven" and return information retreived.

Making Changes

The final version did not have this feature, but at one point CrockBot could make changes to the ingredients at user request. This included multiplying the amounts of the ingredients by some factor, such as if a user asked to double the amount, and completely substituting ingredients for dietary restrictions. For example, asking to make a meal healthier compares the ingredients to a list of unhealthy foods, and halves the amounts of unhealthy food. Making a recipe vegetarian would compare the ingredients to a list of meats, and replace the meats with various vegetable substitutes. There were also some joke options, like making the recipe Italian, which would replace all carbs with spaghetti, or making it Chinese, which would replace all carbs with rice. The user could have a lot of fun with this feature.

Previous
Previous

Backgammon Game Engine and AI Players

Next
Next

2-Space Garbage Collector