Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AmountToString ¶
func GetBestTopHatPositions ¶
GetBestTopHatPositions finds the start and the end of the longest and highest vector.
func SanitizeLine ¶
SanitizeLine removes parentheses, trims the line, converts to lower case, replaces fractions with unicode and then does special conversion for ingredients (like eggs).
Types ¶
type Ingredient ¶
type Ingredient struct {
Name string `json:"name,omitempty"`
Comment string `json:"comment,omitempty"`
Measure Measure `json:"measure,omitempty"`
Frequency float64 `json:"frequency,omitempty`
}
Ingredient is the basic struct for ingredients
type IngredientList ¶
type IngredientList struct {
Ingredients []Ingredient `json:"ingredients"`
}
IngredientList is a list of ingredients
func (IngredientList) String ¶
func (il IngredientList) String() string
type LineInfo ¶
type LineInfo struct {
LineOriginal string
Line string `json:",omitempty"`
IngredientsInString []WordPosition `json:",omitempty"`
AmountInString []WordPosition `json:",omitempty"`
MeasureInString []WordPosition `json:",omitempty"`
Ingredient Ingredient `json:",omitempty"`
}
LineInfo has all the information for the parsing of a given line
type Measure ¶
type Measure struct {
Amount float64 `json:"amount"`
Name string `json:"name"`
Cups float64 `json:"cups"`
Weight float64 `json:"weight"`
}
Measure includes the amount, name and the cups for conversions
type Recipe ¶
type Recipe struct {
FileName string `json:"filename"`
FileContent string `json:"file_content"`
Lines []LineInfo `json:"lines"`
Directions []string `json:"directions"`
Ingredients []Ingredient `json:"ingredients"`
Ratios map[string]map[string]float64 `json:"ratios"`
}
Recipe contains the info for the file and the lines
func NewFromFile ¶
NewFromFile generates a new parser from a file
func NewFromURL ¶
NewFromURL generates a new parser from a url
func (*Recipe) ConvertIngredients ¶
func (*Recipe) IngredientList ¶
func (r *Recipe) IngredientList() (ingredientList IngredientList)
IngredientList will return a string containing the ingredient list
func (*Recipe) Parse ¶
Parse is the main parser for a given recipe. It looks for the following - Contains number - Contains mass/volume - Contains ingredient - Number occurs before ingredient - Number occurs before mass/volume - Number of ingredients is 1 - Percent of other words is less than 50% - Part of list (contains - or *)
func (*Recipe) PrintDirections ¶
func (*Recipe) PrintIngredientList ¶
type WordPosition ¶
WordPosition shows a word and its position Note: the position is memory-dependent as it will be the position after the last deleted word
func GetIngredientsInString ¶
func GetIngredientsInString(s string) (wordPositions []WordPosition)
GetIngredientsInString returns the word positions of the ingredients
func GetMeasuresInString ¶
func GetMeasuresInString(s string) (wordPositions []WordPosition)
GetMeasuresInString returns the word positions of the measures in a ingredient string
func GetNumbersInString ¶
func GetNumbersInString(s string) (wordPositions []WordPosition)
GetNumbersInString returns the word positions of the numbers in the ingredient string