Algorithmic recipes: Difference between revisions

From Hackers & Designers
m (Hd-onions moved page Algorthimic recipe 1 to Algorthimic recipes)
No edit summary
Line 1: Line 1:
During the workshop [[Algorithmic Kitchen]] with [[Luis Rodil-Fernández]] algorithmic recipes were compiled by scraping and sorting a BBC recipe database.
See here 2 delicious examples:
==Algorithmic Chicken Soup==  
==Algorithmic Chicken Soup==  
'''The Human/Machine Recipe Collaboration'''


[[File:Chicken-and-Potato-Soup.png|600px]]
[[File:Chicken-and-Potato-Soup.png|600px]]
      
      
Input:
     import re
     import re
     import operator
     import operator
Line 50: Line 54:
         print ing
         print ing


The Output
 
----------
Output:
 
* freshly chopped onions
* freshly chopped onions
* finely sliced olives
* finely sliced olives
Line 57: Line 62:
* roughly halved chicken
* roughly halved chicken
* thickly grated garlic
* thickly grated garlic


The End...Eat!
The End...Eat!
See our scrapes here: [http://pantry.algorithmickitchen.org:8000/tree pantry.algorithmickitchen.org:8000/]
 


==HOT Algorithms==
==HOT Algorithms==
Line 65: Line 71:
[[File:SichuanCucumber.png|600px]]
[[File:SichuanCucumber.png|600px]]


FROM recipes  
    FROM recipes  
WHERE  
    WHERE  
Description LIKE “%spicy%”
    Description LIKE “%spicy%”
AND description LIKE “%salad%”;
    AND description LIKE “%salad%”;
        ID 1026
        u’Chunky bacon and cucumber salad’
        u’A spicy Sichuan-style salad of cucumber and fried bacon.’
           
            Serves 6
            PT30M
            PT10M


ID 1026
    re = store.find(Recipe, Recipe.id == 1026).any()
u’Chunky bacon and cucumber salad’
    print “name”, re.name
u’A spicy Sichuan-style salad of cucumber and fried bacon.
    #print “photo url”, fs.photo.url
Serves 6
    print re.ingredients.count()
PT30M
PT10M


re = store.find(Recipe, Recipe.id == 1026).any()
    print re.ingredients.count()
print “name”, re.name
#print “photo url”, fs.photo.url
print re.ingredients.count()


print re.ingredients.count()
    for i in re.ingredients:
    print i.name


for i in re.ingredients:
Output:
print i.name


name Chunky bacon and cucumber salad
name Chunky bacon and cucumber salad
16
16
3 tbsp groundnut oil
3 tbsp groundnut oil
18 long dried chillies  
18 long dried chillies  
Line 99: Line 106:
6 tbsp clear rice vinegar or cider vinegar
6 tbsp clear rice vinegar or cider vinegar
6 tbsp toasted sesame oil
6 tbsp toasted sesame oil
600g cucumber, halved lengthways, de-seeded and sliced into 1cm/½in thick wedges
600g cucumber, halved lengthways, de-seeded and sliced into 1cm/½in thick wedges  
pinch sea salt
1 pinch sea salt
3 pinches dried chilli flakes
3 pinches dried chilli flakes
3 tbsp lime juice
3 tbsp lime juice
Line 120: Line 127:
with the chopped coriander, sprinkle over some peanuts, if using, and serve  
with the chopped coriander, sprinkle over some peanuts, if using, and serve  
immediately.’
immediately.’


See our scrapes here: [http://pantry.algorithmickitchen.org:8000/tree pantry.algorithmickitchen.org:8000/]
See our scrapes here: [http://pantry.algorithmickitchen.org:8000/tree pantry.algorithmickitchen.org:8000/]

Revision as of 14:53, 22 November 2015

During the workshop Algorithmic Kitchen with Luis Rodil-Fernández algorithmic recipes were compiled by scraping and sorting a BBC recipe database. See here 2 delicious examples:

Algorithmic Chicken Soup

Chicken-and-Potato-Soup.png

Input:

   import re
   import operator
   
   verbMap = {}
   adjMap = {}
   otherMap = {}
   
   o = store.find(Recipe, Recipe.name.like(u'%onions%'))
   for r in o:
       for i in r.ingredients:
           #print i.name
           l = i.name.split()
           for j in l:
               s = re.sub('[^A-Za-z]+', , j)
               if s.endswith('ly'):
                   if s in adjMap:
                       adjMap[s] += 1
                   else:
                       adjMap[s] = 1
               elif s.endswith('ed') or s.endswith('ing'):
                   if s in verbMap:
                       verbMap[s] += 1
                   else:
                       verbMap[s] = 1
               else:
                   if s in ingMap:
                       ingMap[s] += 1
                   else:
                       ingMap[s] = 1
                
                 
   #for key, value in ingMap.iteritems():
   #    print key, value
       
   sortedAdj = sorted(adjMap.keys(), key=lambda key: adjMap[key], reverse=True)
   for ing in sortedAdj:
     print ing
   print "------"
   sortedVerbs = sorted(verbMap.keys(), key=lambda key: verbMap[key], reverse=True)
   for ing in sortedVerbs:
       print ing
   print "------"
   sortedIng = sorted(ingMap.keys(), key=lambda key: ingMap[key], reverse=True)
   for ing in sortedIng:
       print ing


Output:

  • freshly chopped onions
  • finely sliced olives
  • thinly peeled potatos
  • roughly halved chicken
  • thickly grated garlic


The End...Eat!


HOT Algorithms

SichuanCucumber.png

   FROM recipes 
   WHERE 
   Description LIKE “%spicy%”
   AND description LIKE “%salad%”;

       ID 1026
       u’Chunky bacon and cucumber salad’
       u’A spicy Sichuan-style salad of cucumber and fried bacon.’
            
           Serves 6
           PT30M
           PT10M
   re = store.find(Recipe, Recipe.id == 1026).any()
   print “name”, re.name
   #print “photo url”, fs.photo.url
   print re.ingredients.count()
   print re.ingredients.count()
   for i in re.ingredients:
   print i.name

Output:

name Chunky bacon and cucumber salad 3 tbsp groundnut oil 18 long dried chillies 6 tsp Sichuan peppercorns 3 whole star anise (optional) 300g smoked lardons, cut into 1cm/½in thick pieces 3 red chilli, de-seeded, finely chopped 3 tbsp Shaoxing rice wine or dry sherry 6 tbsp clear rice vinegar or cider vinegar 6 tbsp toasted sesame oil 600g cucumber, halved lengthways, de-seeded and sliced into 1cm/½in thick wedges 1 pinch sea salt 3 pinches dried chilli flakes 3 tbsp lime juice 3 tbsp chilli oil 3 small handful fresh coriander leaves, roughly chopped dry-roasted peanuts (optional)

%%sqlite cookbook.db SELECT id, ordinal, description FROM preparations WHERE recipe_id = 1026 ORDER BY ordinal;

id ordinal description 8652 1 u’Heat a wok until smoking and add the groundnut oil, then add the dried chillies and Sichuan peppercorns. Stir fry for a few seconds, or until fragrant. ‘ 8653 2 u’Add the star anise (if using), bacon lardons and chilli and stir fry for 2-3 minutes, or until the lardons have turned golden-brown at the edges.’ 8654 3 u’Add the rice wine or sherry, vinegar and sesame oil and stir-fry for a few seconds, then add the cucumber and stir-fry for a few more seconds.’ 8655 4 u’Season with sea salt, dried chilli flakes and lime juice, stirring well.’ 8656 5 u’Pile the stir-fry onto a serving plate, drizzle over the chilli oil, garnish with the chopped coriander, sprinkle over some peanuts, if using, and serve immediately.’


See our scrapes here: pantry.algorithmickitchen.org:8000/