# noms -
import noms
import pickle
import os
key=open('myapikey.txt', 'r').read()
#client=noms.Client(key)
#results = client.search_query('Raw Broccoli')
#print(results)
food_dict_daily={
'747447': 100, # Raw Broccoli
'1103064': 1 * 180, # Ripe plantain, raw
'169753' : 100, # Rice, white, long-grain, regular, cooked, enriched, with salt
'1103657': 100, # Vegetable curry
'1100622': 100, # Bread, white, toasted
'1100187': 100, # Egg, whole, fried no added fat
'1099246': 100, # Chicken curry
'1097525': 100, # Milk, lactose free, whole
'1097524': 100, # Milk, lactose free, reduced fat (2%)
'1429086': 100, # ENSURE, HIGH PROTEIN POWDER, VANILLA, VANILLA
'168833' : 100, # Sugars, brown
'1103067': 100, # Plantain chips
'1101716': 100, # Cereal, corn flakes
}
food_dict_daily ={
'1103064': 1 * 180, # Ripe plantain, raw
'169753' : 2 * 185, # Rice, white, long-grain, regular, cooked, enriched, with salt cup
'1103657': 1 * 245, # Vegetable curry cup
'1100622': 0 * 25, # Bread, white, toasted
'1100187': 2 * 49.6, # Egg, whole, fried no added fat
'1099246': 1 * 235, # Chicken curry cup
'1097525': 2 * 244, # Milk, lactose free, whole cup
'1097524': 0 * 244, # Milk, lactose free, reduced fat (2%) cup
'1429086': 1 * (57 * 2)/16, # ENSURE, HIGH PROTEIN POWDER, VANILLA, VANILLA 1 cup = 16 tablespoons, 0.5 cup --> 57 g
'168833' : 2 * 13.56, # Sugars, brown tablespoon
'1103067': 0 * 60, # Plantain chips 1 cup
'1101716': 1 * 88, # Cereal, corn flakes, cup
}
#food_objs = client.get_foods(food_dict_daily)
food_objs = pickle.load(open('mydailyfoodtestbar.pkl', 'rb'))
meal = noms.Meal(food_objs)
r = noms.report(meal)
for i in r:
#print(i)
print(i['name'], '\t', i['rda'], '\t', i['value'])
# scale the y values to 100
for data in r:
if data['rda'] != 0:
conv = 100/data['rda']
data['rda'] = 100
data['value'] *= conv
# termgraph
with open('ytclass_data.dat', 'w') as f:
print('@', 'rda,y_value', file=f)
for data in r:
print(data['name'], data['rda'], data['value'], sep=',', file=f)
#os.system('termgraph ytclass_data.dat --color red blue')
pantry_foods = pickle.load(open('pantry_foods_data.pkl','rb'))
recommendations = noms.generate_recommendations(meal, pantry_foods, noms.nutrient_dict, 3)
for rec in recommendations:
print(round(rec[2] * 100, 2), 'g', "of", pantry_foods[rec[1]].desc)