• Stars
    star
    156
  • Rank 239,589 (Top 5 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 7 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Get a consensus recipe for your next meal. 🍪 🍰

meanrecipe

Sometimes when I want a recipe to cook something new I will find several recipes for the same thing and try to use them as a guide to generate an average or "consensus" recipe. This code should make it easy to generate consensus recipes (useful!) and also show variation between recipes (interesting!).

Finding a consensus recipe requires first clustering many recipes. This is because a single recipe (e.g. a recipe for brownies) might have many significant variations (e.g. brownies can have just cocoa, just chocolate, or both). This code will first cluster recipes and then use the clusters to deliver the consensus recipe.

How does it work

The quick-and-dirty implementation goes like this:

  1. Choose a recipe (e.g. brownies, crepes, pancakes).
  2. Search to find thousands of corresponding recipes.
  3. Download all the recipes convert to gzipped text for processing.
  4. Use a really simple (read: bad) context-extractor to grab ingredients.
  5. Cluster the recipes based on the presence of ingredients.
  6. Take the mean values (after removing outliers) for ingredients in a given cluster to create an average recipe.

The context-extractor works by finding the most likely "ingredient" section in the web page and then trying to parse those ingredients using a greedy search from a list of likely ingredients (top_5k.txt). Its not a great implementation. However, the errors in it are pretty random, which means you can get okay results as long as you have ~hundreds of recipes.

Here's some examples of running the code.

Chocolate chip cookies

$ meanrecipe -recipe 'chocolate chip cookies'

The output will container multiple recipes for 'chocolate chip cookies', clustered according to ingredients. For example, here is the first cluster, the most popular recipe:

Cluster 1 (35% of 1041)

Ingredients:
- 1 teaspoon baking soda (± 42%)
- ⅞ cup brown sugar (± 40%)
- ⅞ cup butter (± 29%)
- 1 ⅝ cup chocolate (± 62%)
- 2 eggs (± 62%)
- 2 ¼ cup flour (± 40%)
- ¾ teaspoon salt (± 67%)
- ¾ cup sugar (± 51%)
- 1 ⅝ teaspoon vanilla (± 75%)

Directions:
1. Preheat oven to 300 degrees F (150 degrees C).

2. Sift together the flour, baking powder and salt, set aside. In a
medium bowl, cream the butter and sugar together until fluffy.
Gradually stir in the dry ingredients, then stir in the walnuts and
chocolate chips.

3. Roll or scoop dough into walnut sized balls. Place them on unprepared
cookie sheets 1 1/2 inches apart. Flatten cookies slightly. Bake for
15 to 20 minutes, until light golden brown. Remove from sheets to cool
on racks.

The second cluster (the second most popular 'chocolate chip cookie' recipe) has pinpointed a variation - the inclusion of baking powder.

Cluster 2 (16% of 1041)
Variation:
 +baking powder

Ingredients:
- 1 ⅛ teaspoon baking powder (± 80%)
- ⅞ teaspoon baking soda (± 49%)
- 1 ⅛ cup brown sugar (± 80%)
- ⅞ cup butter (± 40%)
- 1 ⅝ cup chocolate (± 85%)
- 2 eggs (± 55%)
- 2 ⅛ cup flour (± 51%)
- ¾ teaspoon salt (± 71%)
- ¾ cup sugar (± 80%)
- 2 teaspoon vanilla (± 78%)

Directions:
1. Preheat oven to 300 degrees F (150 degrees C).

2. Sift together the flour, baking powder and salt, set aside. In a
medium bowl, cream the butter and sugar together until fluffy.
Gradually stir in the dry ingredients, then stir in the walnuts and
chocolate chips.

3. Roll or scoop dough into walnut sized balls. Place them on unprepared
cookie sheets 1 1/2 inches apart. Flatten cookies slightly. Bake for
15 to 20 minutes, until light golden brown. Remove from sheets to cool
on racks.

Reading further down you can find even more variations, for example this recipe which uses cocoa:

Cluster 5 (4% of 1041)
Variation:
 +cocoa

Ingredients:
- ¾ teaspoon baking soda (± 57%)
- ¾ cup brown sugar (± 57%)
- ¾ cup butter (± 52%)
- 1 ⅛ cup chocolate (± 72%)
- ⅜ cup cocoa (± 80%)
- 1 eggs (± 44%)
- 1 ½ cup flour (± 67%)
- ⅝ teaspoon salt (± 88%)
- ¾ cup sugar (± 88%)
- 1 ½ teaspoon vanilla (± 67%)

Directions:
1. Preheat oven to 350 degrees F (175 degrees C). Grease cookie sheets.
Stir together the flour, cocoa, baking powder, baking soda, salt and
cinnamon; set aside.

2. In a large bowl, cream together the margarine, brown sugar and white
sugar. Beat in the egg and vanilla. Stir in the dry ingredients using
a wooden spoon. Mix in the oats and chocolate chips. Drop by
tablespoonfuls onto cookie sheets, leaving 2 inches between cookies.

3. Bake for 8 to 10 minutes in the preheated oven, or until lightly
browned.  Allow cookies to cool on baking sheet for 5 minutes before
removing to a wire rack to cool completely.

Try it

Web

You can try it on the web at https://meanrecipe.schollz.com/

Install

Download from the latest releases, or download with Go:

$ go get github.com/schollz/meanrecipe

Run

Just run from the command line and specify the food that you want.

$ meanrecipe -recipe 'chocolate chip cookies'

Be patient as it will take 3-5 minutes to download and pre-process the data. Data is only downloaded once, if you run it a second time it will use the previous data.

You can also generate different number of clusters using -clusters X where X is the number of clusters.

To make sure certain ingredients are included just use -include 'chocolate, oats' (for example).

Roadmap

This is a quick-and-dirty project. I don't plan to do much more on it, it was just a fun thing.

However, here are some things I realize this project does not do and would be great to implement:

  • Making food volumes more accurate. The code specifies a constant density for ingredients that are specified in weight so that they can be converted to volumes (volumes are necessary for normalization before taking means). In reality different foods have different densities, of course.
  • Making proportions more accurate. This will be easier if the previous item is finished.
  • Adding in a specifier for the variation in the amount (show the mean and the standard deviation of the mean?).
  • Adding in recipe directions. Is there a way towards consensus directions? This might be really really hard.
  • In general, making the parsing (from websites) and the food tagging better. There are more sophisticated taggers (see NYT food tagger).

License

MIT

More Repositories

1

croc

Easily and securely send things from one computer to another 🐊 📦
Go
23,068
star
2

howmanypeoplearearound

Count the number of people around you 👨‍👨‍👦 by monitoring wifi signals 📡
Python
6,759
star
3

find

High-precision indoor positioning framework for most wifi-enabled devices.
Go
5,006
star
4

find3

High-precision indoor positioning framework, version 3.
Go
4,494
star
5

progressbar

A really basic thread-safe progress bar for Golang applications
Go
3,367
star
6

hostyoself

Host yo' self from your browser, your phone, your toaster.
Go
1,777
star
7

find-lf

Track the location of every Wi-Fi device (📱) in your house using Raspberry Pis and FIND
Go
977
star
8

rwtxt

A cms for absolute minimalists.
JavaScript
934
star
9

cowyo

A feature-rich wiki webserver for minimalists 🐮 💬
JavaScript
906
star
10

raspberry-pi-turnkey

How to make a Raspberry Pi image that can be deployed anywhere and assigned to a WiFi network without SSH 👌
Python
767
star
11

peerdiscovery

Pure-Go library for cross-platform local peer discovery using UDP multicast 👩 🔁 👩
Go
594
star
12

closestmatch

Golang library for fuzzy matching within a set of strings 📃
Go
407
star
13

gojot

A command-line journal that is distributed and encrypted, making it easy to jot notes 📓
Go
343
star
14

PIanoAI

Realtime piano learning and accompaniment from a Pi-powered AI 🎹
Go
331
star
15

spotifydownload

A dependency-free Spotify playlist downloader that should just work
Shell
318
star
16

poetry-generator

A Python2 based Backus-Naur poetry generator
Python
294
star
17

musicsaur

Music synchronization from your browser.
Go
280
star
18

offlinenotepad

An offline-first, secure, private notepad. 📔 ✏️
JavaScript
236
star
19

pluck

Pluck text in a fast and intuitive way 🐓
Go
214
star
20

pake

PAKE library for generating a strong secret between parties over an insecure channel
Go
180
star
21

miti

miti is a musical instrument textual interface. Basically, its MIDI, but with human-readable text. 🎵
Go
157
star
22

find3-cli-scanner

The command-line scanner that supports Bluetooth and WiFi
Go
142
star
23

playlistfromsong

Create an offline music playlist from a single song 🎶
Python
136
star
24

recursive-recipes

Visualize the recursive nature of recipes 🍰 🍪
Go
135
star
25

teoperator

Make OP-1 and OP-Z drum and synth patches from any sound. 🎹
Go
134
star
26

jsonstore

Simple thread-safe in-memory JSON key-store with persistent backend
Go
130
star
27

getsong

Download any song mp3 with no dependencies except ffmpeg
Go
124
star
28

find3-android-scanner

An android app that scans Bluetooth and WiFi for FIND3
Java
119
star
29

linkcrawler

Cross-platform persistent and distributed web crawler 🔗
Go
111
star
30

ingredients

Extract recipe ingredients from any recipe website on the internet.
HTML
109
star
31

share

Simple file sharing from the browser and the command-line.
Go
106
star
32

faas

Make any Go function into a API (FaaS)
Go
96
star
33

_core

firmware for the zeptocore, zeptoboard, and ectocore
C
77
star
34

find-maraudersmap

Internal positioning for everyone, in the style of Harry Potter
HTML
67
star
35

broadcast-server

A simple Go server that broadcasts any data/stream.
Go
65
star
36

streammyaudio

Easily stream audio from any computer to the internet.
HTML
63
star
37

cowyodel

Easily move things between computers with a code phrase and https://cowyo.com 🐮 💬
Go
62
star
38

extract_recipe

Extract recipes from websites, calculates cooking times, collects nutrition info from USDA database
Python
61
star
39

crawdad

Cross-platform persistent and distributed web crawler 🦀
Go
61
star
40

pikocore

source for the pikocore drum machine
C++
60
star
41

duct

Inspired by patchbay.pub
Go
59
star
42

svg2gcode

Converts svg to gcode for pen plotters
Go
53
star
43

snaptext

A simple webapp to send and receive self-destructing messages in real-time. ✉️ ⚡
Go
53
star
44

pywebsitechanges

Change detection with a simple Python script to email you whenever a website changes.
Python
51
star
45

rpi_ai

An AI developed for the Raspberry Pi
Python
50
star
46

websitechanges

Alerts you via email about a website change.
Go
47
star
47

kiki

An experimental social network that works offline.
Go
46
star
48

goagrep

agrep-like fuzzy matching, but made faster using Golang and precomputation.
Go
45
star
49

oooooo

digital tape loops for monome norns, x6.
Lua
43
star
50

readable

Making web pages readable in a browser and in the command line 🔗 📖
Go
41
star
51

onetwothree

A responsive minimalist theme for Hugo that is simple as 1, 2, 3
CSS
39
star
52

logue

A collection of Korg logue patches for the NTS-1 (or possibly minilogue XD)
C
37
star
53

midi2cv-pi

Use a simple Python script, a few wires, and a MCP4725 to convert any MIDI signal to a control voltage.
Python
37
star
54

sqlite3dump

A Golang library for dumping SQL text
Go
35
star
55

wifiscan

A platform-independent WiFi scanning library for getting BSSID + RSSI
Go
35
star
56

norns.online

online norns with norns.online
Go
35
star
57

bol

Command-line and web journal that stays synchronized and encrypted across devices
Go
34
star
58

syncdir

Automatically discover peers and synchronize a folder
Go
33
star
59

18000

18,000 seconds of music.
SuperCollider
32
star
60

nyblcore

ATtiny85-based sample machine with tempo-based effects.
C++
31
star
61

beowulf_ssh_cluster

Skeleton program for a simple Beowulf cluster that uses ssh to communicate
Python
31
star
62

markdown2tufte

Process markdown into a nice Tufte-like website 📖
CSS
31
star
63

carp

Browser-based Korg NTS-1 chord arpeggiator (carp) sequencer
JavaScript
28
star
64

httpfileserver

Wrapper for Golang http.FileServer that is faster (serving from memory) and uses less bandwidth (gzips when possible)
Go
27
star
65

browsersync

A simple live-reloading tool for developing HTML.
Go
26
star
66

tape-synth

Instructions to create a cassette synthesizer.
Go
26
star
67

squirrel

Like curl, or wget, but downloads directly go to a SQLite databse
Go
25
star
68

workshops

workshops
SuperCollider
23
star
69

patchitup

Backup your file to your remote server using minimum bandwidth.
Go
23
star
70

norns-desktop

norns in docker
Dockerfile
22
star
71

logger

Simplistic, opinionated logging for Golang
Go
21
star
72

mnemonicode

Go
20
star
73

boltdb-server

Fancy server and Go package for connecting to BoltDB databases
Go
20
star
74

zget

zack's wget
Go
19
star
75

wormhole

Transfer files over TCP in Go
Go
19
star
76

quotation-explorer

Explore and search over 120,000 quotations, with the click of a mouse 🌎💬
Go
19
star
77

o-o-o

dot-connected fm synth and sequencer for norns
Lua
18
star
78

tapedeck

norns tape deck emulator.
Lua
17
star
79

amenbreak

a dedicated amen break script for norns.
Lua
16
star
80

zxcvbn

a norns script for a tracker on norns.
Lua
16
star
81

anonfiction

A CMS for reading and writing stories in a online magazine format. 📖
Go
16
star
82

prevent-link-rot

Simple utility to convert links in any file to permanent links via the https://archive.org/web/ or http://perma.cc
HTML
16
star
83

raw

Go
16
star
84

mx.samples

like mr. radar or mr.coffee but for samples on norns.
Lua
15
star
85

supertonic

an instrospective drum machien
Lua
15
star
86

mx.synths

norns script for polyphonic synths
Lua
14
star
87

autojack

norns mod for automatically jacking in usb audio
Lua
14
star
88

fbdb

File based database
Go
14
star
89

broadcast

Lua
14
star
90

paracosms

norns script to play and sample many samples.
Lua
14
star
91

heartbpm

Control the tempo of electronic instruments with your heart rate. 💗 🎵
JavaScript
14
star
92

web-archiver

A tiny Python clone of https://archive.org/web/ for your own personal websites.
Python
13
star
93

album-at-the-place

Open-sourcing my latest music album.
12
star
94

indeterminate-music

A framework for creating indeterminate music (in development) 🎵
HTML
12
star
95

ipfs-connect

Easily connect two computers in the IPFS
Go
11
star
96

googleit

Get results from search engines.
Go
11
star
97

stringsizer

A very simple way to encode short strings.
Go
11
star
98

supercollisions

collection of SuperCollider scripts
SuperCollider
11
star
99

amen

sampler & mangler for monome norns
Lua
11
star
100

string_matching

A simple and fast approach to selecting the best string in a list of strings despite errors or mispelling.
Python
11
star