<commit_before>"""
DrinkRecipe class encapsulates how a drink recipe is calculated and formulated,
can provide itself as a dict/json, tuple of values, do conversions, etc.
Just generally make it better OOP
"""
import re
from fractions import Fraction
from recordtype import recordtype
import itertools

import util

# water volume added by preperation method for ABV estimate
# TODO by ice and prep instead -e.g. build, highball, cubed vs build, flute, neat
WATER_BY_PREP = {'shake': 1.65, 'stir': 1.3, 'build': 1.0}

class RecipeError(StandardError):
    pass

class DrinkRecipe(object):
    """ Initialize a drink with a handle to the available stock data and its recipe json
    """
    RecipeExample = recordtype('RecipeExample', [('bottles', []), ('cost', 0), ('abv', 0), ('std_drinks', 0), ('volume', 0)])
    RecipeStats = recordtype('RecipeStats', 'min_cost,max_cost,min_abv,max_abv,min_std_drinks,max_std_drinks,volume', default=RecipeExample)

    @util.default_initializer
    def __init__(self, name, recipe_dict, stock_df=None):
        # from recipe dict pull out other info and set defaults
        self.info      =  recipe_dict.get('info',      '')
        self.iba_info  =  recipe_dict.get('IBA_description', '')
        self.origin    =  recipe_dict.get('origin',    '')
        self.unit      =  recipe_dict.get('unit',      'oz') # cL, mL, tsp, dash, drop, bar spoon
        self.prep      =  recipe_dict.get('prep',      'shake') # build, stir
        self.ice       =  recipe_dict.get('origin',    'cubed') # crushed
        self.glass     =  recipe_dict.get('glass',     'cocktail') # rocks, martini, champagne flute
        self.variants  =  recipe_dict.get('variants',  [])
        self.max_cost     =  0<commit_msg>Defaults formarring for DrinkRecipe class<commit_after>"""
DrinkRecipe class encapsulates how a drink recipe is calculated and formulated,
can provide itself as a dict/json, tuple of values, do conversions, etc.
Just generally make it better OOP
"""
import re
from fractions import Fraction
from recordtype import recordtype
import itertools

import util

# water volume added by preperation method for ABV estimate
# TODO by ice and prep instead -e.g. build, highball, cubed vs build, flute, neat
WATER_BY_PREP = {'shake': 1.65, 'stir': 1.3, 'build': 1.0}

class RecipeError(StandardError):
    pass

class DrinkRecipe(object):
    """ Initialize a drink with a handle to the available stock data and its recipe json
    """
    RecipeExample = recordtype('RecipeExample', [('bottles', []), ('cost', 0), ('abv', 0), ('std_drinks', 0), ('volume', 0)])
    RecipeStats = recordtype('RecipeStats', 'min_cost,max_cost,min_abv,max_abv,min_std_drinks,max_std_drinks,volume', default=RecipeExample)

    @util.default_initializer
    def __init__(self, name, recipe_dict, stock_df=None):
        # from recipe dict pull out other info and set defaults
        self.info      =  recipe_dict.get('info', '')
        self.iba_info  =  recipe_dict.get('IBA_description', '')
        self.origin    =  recipe_dict.get('origin', '')
        self.unit      =  recipe_dict.get('unit', 'oz') # cL, mL, tsp, dash, drop
        self.prep      =  recipe_dict.get('prep', 'shake') # build, stir, blend
        self.ice       =  recipe_dict.get('origin', 'cubed') # crushed, neat
        self.glass     =  recipe_dict.get('glass', 'cocktail') # rocks, martini, flute, collins, highball
        self.variants  =  recipe_dict.get('variants',  [])
        self.max_cost     =  0
{'fraction_non_alphanumeric': 0.1221395881006865, 'fraction_numerical': 0.006864988558352402, 'mean_word_length': 3.5356679636835278, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6828747', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1108, 'n_words': 326}