I once hacked together some very basic code to try and do this, so that I could answer the question "what can I make with the stuff in my refrigerator".
I gave up on the project pretty quickly (now I'm really tempted to pick it up again), but you can definitely get 90% of the way there with 10% of the effort:
ingredients = [
'200g of heavily salted butter',
'six bottles of beer',
'50ml of clotted cream',
'plain brown flour',
'1 oz french cheese',
'8 large eggs',
'2kg of salted pork',
'a pinch of salt',
'a tablespoon of honey'
]
ingredients.map { |i| IngredientParser.parse i }
# => ["butter",
# "beer",
# "clotted cream",
# "flour",
# "cheese",
# "egg",
# "pork",
# "salt",
# "honey"]
https://github.com/cronin101/DataChef/blob/master/utils/ingr... require '../environment.rb'
require '../scrapers/bbc_good_food_scraper.rb'
recipe = Recipe.create source_uri: 'http://www.bbcgoodfood.com/recipes/vietnamese-caramel-trout'
recipe.update_using_scraper BBCGoodFoodScraper
puts recipe.title
puts recipe.description
puts recipe.ingredient_ids.inspect
recipe.ingredient_ids.each { |i| puts((Ingredient.find i).inspect) }
=begin
Vietnamese caramel trout
A caramel base balances out the hot and salty ingredients of this Asian-inspired one-pan fish dish for two
[56, 57, 58, 59, 60, 61, 62, 63, 64]
#<Ingredient id: 56, name: "caster sugar", recipe_frequency: 1, recipe_ids: [7]>
#<Ingredient id: 57, name: "thai fish sauce", recipe_frequency: 1, recipe_ids: [7]>
#<Ingredient id: 58, name: "red chilli", recipe_frequency: 1, recipe_ids: [7]>
#<Ingredient id: 59, name: "ginger", recipe_frequency: 1, recipe_ids: [7]>
#<Ingredient id: 60, name: "rainbow trout", recipe_frequency: 1, recipe_ids: [7]>
#<Ingredient id: 61, name: "bok choi", recipe_frequency: 1, recipe_ids: [7]>
#<Ingredient id: 62, name: "juice lemon", recipe_frequency: 1, recipe_ids: [7]>
#<Ingredient id: 63, name: "coriander", recipe_frequency: 1, recipe_ids: [7]>
#<Ingredient id: 64, name: "rice", recipe_frequency: 1, recipe_ids: [7]>
=end