Spaces:
Sleeping
Sleeping
File size: 11,738 Bytes
f8c0ae2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
from load_data import items
# Example of populating unique_items
unique_items = set(item for sublist in items for item in sublist)
# Flatten the list of lists
flattened_list = [item for sublist in items for item in sublist]
# Get unique items by converting the list to a set
unique_items_set = set(flattened_list)
# Optional: Convert the set back to a list if you need it in list form
unique_items_list = list(unique_items_set)
# Define the categories and products mapping
product_to_category = {
'salmon': {'category': 'seafood', 'image': 'resized_images/salmon.png'},
'tea': {'category': 'beverages', 'image': 'resized_images/tea.png'},
'cottage cheese': {'category': 'dairy', 'image': 'resized_images/cottage cheese.png'},
'nuggets': {'category': 'meat', 'image': 'resized_images/nuggets.png'},
'gums': {'category': 'snacks', 'image': 'resized_images/gums.png'},
'shampoo': {'category': 'personal care', 'image': 'resized_images/shampoo.png'},
'water spray': {'category': 'personal care', 'image': 'resized_images/water spray.png'},
'ketchup': {'category': 'condiments', 'image': 'resized_images/ketchup.png'},
'protein bar': {'category': 'snacks', 'image': 'resized_images/protein bar.png'},
'butter': {'category': 'dairy', 'image': 'resized_images/butter.png'},
'green grapes': {'category': 'fruits', 'image': 'resized_images/green grapes.png'},
'pickles': {'category': 'condiments', 'image': 'resized_images/pickles.png'},
'meatballs': {'category': 'meat', 'image': 'resized_images/meatballs.png'},
'toothpaste': {'category': 'personal care', 'image': 'resized_images/toothpaste.png'},
'body spray': {'category': 'personal care', 'image': 'resized_images/body spray.png'},
'shrimp': {'category': 'seafood', 'image': 'resized_images/shrimp.png'},
'oil': {'category': 'cooking essentials', 'image': 'resized_images/oil.png'},
'flax seed': {'category': 'cooking essentials', 'image': 'resized_images/flax seed.png'},
'chutney': {'category': 'condiments', 'image': 'resized_images/chutney.png'},
'asparagus': {'category': 'vegetables', 'image': 'resized_images/asparagus.png'},
'avocado': {'category': 'fruits', 'image': 'resized_images/avocado.png'},
'light mayo': {'category': 'condiments', 'image': 'resized_images/light mayo.png'},
'salad': {'category': 'vegetables', 'image': 'resized_images/salad.png'},
'eggplant': {'category': 'vegetables', 'image': 'resized_images/eggplant.png'},
'cooking oil': {'category': 'cooking essentials', 'image': 'resized_images/cooking oil.png'},
'salt': {'category': 'cooking essentials', 'image': 'resized_images/salt.png'},
'extra dark chocolate': {'category': 'snacks', 'image': 'resized_images/extra dark chocolate.png'},
'magazines': {'category': 'miscellaneous', 'image': 'resized_images/magazines.png'},
'antioxydant juice': {'category': 'beverages', 'image': 'resized_images/antioxydant juice.png'},
'apple juice': {'category': 'beverages', 'image': 'resized_images/apple juice.png'},
'honey': {'category': 'cooking essentials', 'image': 'resized_images/honey.png'},
'chili': {'category': 'vegetables', 'image': 'resized_images/chili.png'},
'babies food': {'category': 'baby care', 'image': 'resized_images/babies food.png'},
'cider': {'category': 'beverages', 'image': 'resized_images/cider.png'},
'vegetables mix': {'category': 'vegetables', 'image': 'resized_images/vegetables mix.png'},
'redbull': {'category': 'beverages', 'image': 'resized_images/redbull.png'},
'cheese cake': {'category': 'desserts', 'image': 'resized_images/cheese cake.png'},
'herb & pepper': {'category': 'spices', 'image': 'resized_images/herb & pepper.png'},
'cereals': {'category': 'breakfast', 'image': 'resized_images/cereals.png'},
'corn': {'category': 'vegetables', 'image': 'resized_images/corn.png'},
'mayonnaise': {'category': 'condiments', 'image': 'resized_images/mayonnaise.png'},
'carrots': {'category': 'vegetables', 'image': 'resized_images/carrots.png'},
'napkins': {'category': 'household', 'image': 'resized_images/napkins.png'},
'chocolate': {'category': 'snacks', 'image': 'resized_images/chocolate.png'},
'soup': {'category': 'canned goods', 'image': 'resized_images/soup.png'},
'yams': {'category': 'vegetables', 'image': 'resized_images/yams.png'},
'cake': {'category': 'desserts', 'image': 'resized_images/cake.png'},
'mint': {'category': 'spices', 'image': 'resized_images/mint.png'},
'spaghetti': {'category': 'pasta', 'image': 'resized_images/spaghetti.png'},
'pasta': {'category': 'pasta', 'image': 'resized_images/pasta.png'},
'fromage blanc': {'category': 'dairy', 'image': 'resized_images/fromage blanc.png'},
'fresh bread': {'category': 'bakery', 'image': 'resized_images/fresh bread.png'},
'cream': {'category': 'dairy', 'image': 'resized_images/cream.png'},
'ground beef': {'category': 'meat', 'image': 'resized_images/ground beef.png'},
'eggs': {'category': 'breakfast', 'image': 'resized_images/eggs.png'},
'chicken': {'category': 'meat', 'image': 'resized_images/chicken.png'},
'hand protein bar': {'category': 'snacks', 'image': 'resized_images/hand protein bar.png'},
'energy drink': {'category': 'beverages', 'image': 'resized_images/energy drink.png'},
'oatmeal': {'category': 'breakfast', 'image': 'resized_images/oatmeal.png'},
'cookies': {'category': 'snacks', 'image': 'resized_images/cookies.png'},
'muffins': {'category': 'bakery', 'image': 'resized_images/muffins.png'},
'frozen vegetables': {'category': 'frozen foods', 'image': 'resized_images/frozen vegetables.png'},
'almonds': {'category': 'nuts', 'image': 'resized_images/almonds.png'},
'beef': {'category': 'meat', 'image': 'resized_images/beef.png'},
'bug spray': {'category': 'household', 'image': 'resized_images/bug spray.png'},
'tomato sauce': {'category': 'condiments', 'image': 'resized_images/tomato sauce.png'},
'spinach': {'category': 'vegetables', 'image': 'resized_images/spinach.png'},
'sparkling water': {'category': 'beverages', 'image': 'resized_images/sparkling water.png'},
'cauliflower': {'category': 'vegetables', 'image': 'resized_images/cauliflower.png'},
'whole wheat rice': {'category': 'grains', 'image': 'resized_images/whole wheat rice.png'},
'chocolate bread': {'category': 'bakery', 'image': 'resized_images/chocolate bread.png'},
'burger sauce': {'category': 'condiments', 'image': 'resized_images/burger sauce.png'},
'shallot': {'category': 'vegetables', 'image': 'resized_images/shallot.png'},
'whole weat flour': {'category': 'cooking essentials', 'image': 'resized_images/whole weat flour.png'},
'white wine': {'category': 'beverages', 'image': 'resized_images/white wine.png'},
'barbecue sauce': {'category': 'condiments', 'image': 'resized_images/barbecue sauce.png'},
'fresh tuna': {'category': 'seafood', 'image': 'resized_images/fresh tuna.png'},
'blueberries': {'category': 'fruits', 'image': 'resized_images/blueberries.png'},
'energy bar': {'category': 'snacks', 'image': 'resized_images/energy bar.png'},
'sandwich': {'category': 'snacks', 'image': 'resized_images/sandwich.png'},
'light cream': {'category': 'dairy', 'image': 'resized_images/light cream.png'},
'olive oil': {'category': 'cooking essentials', 'image': 'resized_images/olive oil.png'},
'clothes accessories': {'category': 'miscellaneous', 'image': 'resized_images/clothes accessories.png'},
'mushroom cream sauce': {'category': 'sauces', 'image': 'resized_images/mushroom cream sauce.png'},
'escalope': {'category': 'meat', 'image': 'resized_images/escalope.png'},
'pancakes': {'category': 'breakfast', 'image': 'resized_images/pancakes.png'},
'black tea': {'category': 'beverages', 'image': 'resized_images/black tea.png'},
'grated cheese': {'category': 'dairy', 'image': 'resized_images/grated cheese.png'},
'whole wheat pasta': {'category': 'pasta', 'image': 'resized_images/whole wheat pasta.png'},
'mineral water': {'category': 'beverages', 'image': 'resized_images/mineral water.png'},
'tomato juice': {'category': 'beverages', 'image': 'resized_images/tomato juice.png'},
'candy bars': {'category': 'snacks', 'image': 'resized_images/candy bars.png'},
'pepper': {'category': 'spices', 'image': 'resized_images/pepper.png'},
'pet food': {'category': 'pet care', 'image': 'resized_images/pet food.png'},
'french fries': {'category': 'snacks', 'image': 'resized_images/french fries.png'},
'green beans': {'category': 'vegetables', 'image': 'resized_images/green beans.png'},
'strawberries': {'category': 'fruits', 'image': 'resized_images/strawberries.png'},
'melons': {'category': 'fruits', 'image': 'resized_images/melons.png'},
'zucchini': {'category': 'vegetables', 'image': 'resized_images/zucchini.png'},
'brownies': {'category': 'desserts', 'image': 'resized_images/brownies.png'},
'milk': {'category': 'dairy', 'image': 'resized_images/milk.png'},
'bramble': {'category': 'fruits', 'image': 'resized_images/bramble.png'},
'low fat yogurt': {'category': 'dairy', 'image': 'resized_images/low fat yogurt.png'},
'yogurt cake': {'category': 'desserts', 'image': 'resized_images/yogurt cake.png'},
'frozen smoothie': {'category': 'frozen foods', 'image': 'resized_images/frozen smoothie.png'},
'mint green tea': {'category': 'beverages', 'image': 'resized_images/mint green tea.png'},
'tomatoes': {'category': 'vegetables', 'image': 'resized_images/tomatoes.png'},
'strong cheese': {'category': 'dairy', 'image': 'resized_images/strong cheese.png'},
'nonfat milk': {'category': 'dairy', 'image': 'resized_images/nonfat milk.png'},
'green tea': {'category': 'beverages', 'image': 'resized_images/green tea.png'},
'rice': {'category': 'grains', 'image': 'resized_images/rice.png'},
'hot dogs': {'category': 'meat', 'image': 'resized_images/hot dogs.png'},
'soda': {'category': 'beverages', 'image': 'resized_images/soda.png'},
'mashed potato': {'category': 'vegetables', 'image': 'resized_images/mashed potato.png'},
'turkey': {'category': 'meat', 'image': 'resized_images/turkey.png'},
'french wine': {'category': 'beverages', 'image': 'resized_images/french wine.png'},
'parmesan cheese': {'category': 'dairy', 'image': 'resized_images/parmesan cheese.png'},
'gluten free bar': {'category': 'snacks', 'image': 'resized_images/gluten free bar.png'},
'burgers': {'category': 'meat', 'image': 'resized_images/burgers.png'}
}
# Initialize the goal format dictionary
goal_format = {
"beverages": [],
"dairy": [],
"snacks": [],
"seafood": [],
"personal care": [],
"vegetables": [],
"fruits": [],
"condiments": [],
"cooking essentials": [],
"meat": [],
"baby care": [],
"frozen foods": [],
"nuts": [],
"household": [],
"breakfast": [],
"bakery": [],
"spices": [],
"canned goods": [],
"desserts": [],
"pasta": [],
"grains": [],
"pet care": [],
"sauces": [],
"miscellaneous": [],
}
# Populate the goal_format dictionary with products from the unique_items_list
for product in unique_items_list:
category_dict = product_to_category.get(product) # Get the category dictionary
if category_dict:
category_name = category_dict['category'] # Extract the category name (string)
goal_format[category_name].append(product) # Use category name as key
# Optional: Remove duplicates (if any) in the product lists
for category in goal_format:
goal_format[category] = list(set(goal_format[category])) |