News for hackers. Stuff that matters.
Re:Show HN: An API for scraping recipe web pages by cronin101 on Tuesday July 18, 2017 @07:44AM (#14795755)
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
Re:Show HN: An API for scraping recipe web pages by tinebak on Tuesday July 18, 2017 @08:01AM (#14795795)
I'm working on this and finding that it's a lot of work (and code) to identify the actual ingredient. Consider "all-purpose sifted flour." That's the same ingredient as "plain flour." So (so!) many ways to write the same ingredient. I'm getting there, though :)
Re:Show HN: An API for scraping recipe web pages by cronin101 on Thursday July 20, 2017 @06:14AM (#14811222)
I believe this is "easily" solved by using POS tagging. "flour" is the noun so you can throw the rest away?

That was my approach.