Documentation
¶
Index ¶
- Variables
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func CreateClusters(folder string, numClusters int, requiredIngredients []string) (err error)
- func DetermineIngredients(line string) (ingredients []string)
- func DownloadAll(folder string, urls []string) (err error)
- func DownloadOne(folder, url string) (fname string, err error)
- func GetAllRecipes(folder string) (err error)
- func GetDirections(recipe string, include []string, exclude []string) (directions []string, err error)
- func GetIngredientLines(fname string) (ingredientLines []string, err error)
- func HasRecipe(recipe string) (yes bool)
- func IsIngredient(s string) (yes bool)
- func ListGzFiles(folder string) (files []string, err error)
- func MustAsset(name string) []byte
- func ReadGzFile(filename string) ([]byte, error)
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- func SetLogLevel(level string) (err error)
- func Singularlize(line string) string
- type Cluster
- type Collection
- type Ingredient
- type Rational
- type Recipe
Constants ¶
This section is empty.
Variables ¶
var UseTor bool
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/
foo.txt
img/
a.png
b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func CreateClusters ¶
func DetermineIngredients ¶
DetermineIngredients will look through a list of ingredients from longest name to shortest, and pick the first one that is in the line
func DownloadAll ¶
func DownloadOne ¶
func GetAllRecipes ¶
GetALlRecipes will gather all recipes in a folder
func GetDirections ¶
func GetIngredientLines ¶
GetIngredientLines returns the ingredient lines
func IsIngredient ¶
func ListGzFiles ¶
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func ReadGzFile ¶
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
func Singularlize ¶
Types ¶
type Cluster ¶
type Cluster struct {
Recipes []Recipe `json:"recipes,omitempty"`
ID int `json:"id,omitempty"`
NumRecipes int `json:"num_recipes,omitempty"`
IngredientRelations map[string]Collection `json:"ingredient_relations_collection,omitempty"`
Ingredient map[string]Collection `json:"ingredient_collection,omitempty"`
}
type Collection ¶
type Collection struct {
Number int `json:"num,omitempty"`
All []float64 `json:"all,omitempty"`
Average float64 `json:"average,omitempty"`
SD float64 `json"sd,omitempty"`
}
func ProcessCollection ¶
func ProcessCollection(c Collection) Collection
type Ingredient ¶
type Ingredient struct {
OriginalLine string `json:"line,omitempty"`
Ingredient string `json:"ingredient,omitempty"`
Measure string `json:"measure,omitempty"`
Amount float64 `json:"amount,omitempty"`
// the following are specific to clusters
Cups float64 `json:"cups,omitempty"`
SD float64 `json:"sd,omitempty"`
FrequencyInCluster float64 `json:"freq_cluster,omitempty"`
}
Ingredient species the ingredients
func ParseIngredients ¶
func ParseIngredients(fname string) (ingredients []Ingredient, err error)
ParseIngredients will return the ingredients found in the file
func (Ingredient) String ¶
func (p Ingredient) String() string
type Rational ¶
type Rational struct {
// contains filtered or unexported fields
}
A rational number r is expressed as the fraction p/q of two integers: r = p/q = (d*i+n)/d.
func ParseDecimal ¶
type Recipe ¶
type Recipe struct {
URL string `json:"url,omitempty"`
Filename string `json:"filename,omitempty"`
Ingredients []Ingredient `json:"ingredients,omitempty"`
Directions []string `json:"directions,omitempty"`
VolumeRelations map[string]float64 `json:"volume_relations,omitempty"`
Title string `json:"title,omitempty"`
// the following are specific to clusters
PercentOfAll int `json:"percent_of_all,omitempty"`
NumberInCluster int `json:"number_in_cluster,omitempty"`
TotalRecipes int `json:"total_recipes,omitempty"`
URLs []string `json:"urls,omitempty"`
HasRareIngredients []string `json:"rare_ingredients,omitempty"`
MissingCommonIngredients []string `json:"missing_ingredients,omitempty"`
}
Recipe is the parsed recipe from a file
func AnalyzeClusters ¶
func GenerateRecipe ¶
GenerateRecipe will parse the recipe from a file