Ver Fonte

TG-28: Expand nutrition dataset to 142 foods (add tuna, seafood, fruit, veg, dairy) and fix seeder table init

FerRo988 há 4 semanas atrás
pai
commit
6ccf0f978a
3 ficheiros alterados com 118 adições e 4 exclusões
  1. 103 1
      nutrition.csv
  2. 7 3
      seed_food_db.py
  3. 8 0
      verify_search.py

+ 103 - 1
nutrition.csv

@@ -1,41 +1,143 @@
 name,calories,protein,fat,carbohydrate,fiber,sugar,sodium
 Chicken Breast (Raw),120,22.5,2.6,0,0,0,45
+Chicken Thigh (Raw),153,17.4,9.3,0,0,0,77
+Chicken Drumstick (Raw),143,18.5,7.4,0,0,0,82
 Ground Beef (80% Lean),254,17.2,20,0,0,0,66
+Ground Beef (95% Lean),152,21.4,7,0,0,0,75
+Beef Steak (Sirloin),207,26.1,11,0,0,0,57
+Beef Ribeye,291,24.4,20.7,0,0,0,68
+Pork Loin (Raw),165,22.2,8.2,0,0,0,55
+Pork Chop,187,21.6,10.6,0,0,0,62
+Bacon (Cooked),541,37,42,1.4,0,0,1717
+Ham (Cooked),163,21.5,7.9,1.3,0,1,1203
+Turkey Breast (Raw),104,23.1,1.2,0,0,0,56
+Turkey Ground,218,22,14,0,0,0,80
+Lamb Chop,294,19.9,23.4,0,0,0,72
+Tuna (Canned in Water),116,25.5,1,0,0,0,333
+Tuna (Fresh, Raw),144,23.3,4.9,0,0,0,47
 Salmon (Raw),208,20,13,0,0,0,59
+Salmon (Smoked),117,18.3,4.3,0,0,0,784
+Sardines (Canned),208,24.6,11.5,0,0,0,505
+Shrimp (Raw),99,20.3,1.7,0.2,0,0,111
+Cod (Raw),82,17.8,0.7,0,0,0,54
+Tilapia (Raw),96,20.1,2,0,0,0,56
+Mackerel (Raw),205,18.6,13.9,0,0,0,83
+Halibut (Raw),111,20.8,2.3,0,0,0,54
+Sea Bass (Raw),124,23.6,2.6,0,0,0,68
+Shrimp (Cooked),99,20.9,1.1,0.9,0,0,943
 Tofu (Firm),144,15.8,8.7,2.8,2.3,0.6,14
+Tofu (Silken),55,4.8,2.7,2.4,0.1,0.4,8
 Eggs (Whole),143,12.6,9.5,0.7,0,0.4,142
+Egg Whites,52,10.9,0.2,0.7,0,0.7,166
+Egg Yolk,322,15.9,26.5,3.6,0,0.6,48
+Tempeh,193,18.5,10.8,9.4,0,0,9
+Edamame,121,11.9,5.2,8.9,5.2,2.2,6
 White Rice (Cooked),130,2.7,0.3,28.2,0.4,0.1,1
 Brown Rice (Cooked),111,2.6,0.9,23,1.8,0.4,5
+Basmati Rice (Cooked),121,2.5,0.4,25.2,0.4,0,1
+Jasmine Rice (Cooked),129,2.9,0.4,27.6,0.3,0,1
 Pasta (Cooked),131,5.2,1.2,25,1.2,0.6,6
+Pasta (Whole Wheat, Cooked),124,5.3,0.5,26.5,3.9,0.5,4
+Spaghetti (Cooked),158,5.8,0.9,30.6,1.8,0.6,1
 Sweet Potato (Baked),90,2,0.1,20.7,3.3,4.2,36
 Potato (Baked),93,2.5,0.1,21.2,2.2,1.2,10
+Potato (Boiled),77,1.9,0.1,17.8,1.8,0.8,5
+French Fries,312,3.4,15,41,3.8,0,210
 Oats (Rolled),389,16.9,6.9,66.3,10.6,0,2
 Quinoa (Cooked),120,4.4,1.9,21.3,2.8,0.9,7
 Lentils (Cooked),116,9,0.4,20.1,7.9,1.8,2
 Black Beans (Cooked),132,8.9,0.5,23.7,8.7,0.3,1
 Chickpeas (Cooked),164,8.9,2.6,27.4,7.6,4.8,7
+Kidney Beans (Cooked),127,8.7,0.5,22.8,6.4,0.3,2
+Green Lentils (Cooked),116,9,0.4,20.1,7.9,1.8,2
+Split Peas (Cooked),116,8.3,0.4,20.8,8.1,2.8,2
+Pinto Beans (Cooked),143,9.5,0.6,26.2,7.4,0.2,283
+White Beans (Cooked),139,9.7,0.4,25,6.3,0.3,2
 Broccoli,34,2.8,0.4,6.6,2.6,1.7,33
 Spinach,23,2.9,0.4,3.6,2.2,0.4,79
+Kale,49,4.3,0.9,8.8,3.6,2.3,38
 Asparagus,20,2.2,0.1,3.9,2.1,1.9,2
 Carrots,41,0.9,0.2,9.6,2.8,4.7,69
 Bell Pepper (Red),31,1,0.3,6,2.1,4.2,4
+Bell Pepper (Green),20,0.9,0.2,4.6,1.7,2.4,3
 Tomato,18,0.9,0.2,3.9,1.2,2.6,5
+Cherry Tomato,18,0.9,0.2,3.9,1.2,2.6,5
 Onion,40,1.1,0.1,9.3,1.7,4.2,4
 Garlic,149,6.4,0.5,33.1,2.1,1,15
+Cucumber,15,0.7,0.1,3.6,0.5,1.7,2
+Zucchini,17,1.2,0.3,3.1,1,2.5,8
+Eggplant,25,1,0.2,5.9,3,3.5,2
+Mushrooms (Button),22,3.1,0.3,3.3,1,2,5
+Mushrooms (Shiitake),39,2.2,0.5,7.7,2.5,2.4,6
+Celery,16,0.7,0.2,3,1.6,1.3,80
+Cauliflower,25,2,0.3,5,2,2,30
+Brussels Sprouts,43,3.4,0.3,8.9,3.8,2.2,25
+Green Beans,31,1.8,0.2,7,2.7,1.4,6
+Corn (Sweet),86,3.3,1.4,19,2.7,6.3,15
+Peas (Green),81,5.4,0.4,14.5,5.1,5.7,5
+Lettuce (Romaine),17,1.2,0.3,3.3,2.1,1.5,8
+Lettuce (Iceberg),14,0.9,0.1,2.9,1.3,2,10
+Cabbage,25,1.3,0.1,5.8,2.5,3.2,18
+Beetroot,43,1.6,0.2,9.6,2.8,6.8,78
 Apple,52,0.3,0.2,13.8,2.4,10.4,1
 Banana,89,1.1,0.3,22.8,2.6,12.2,1
 Orange,47,0.9,0.1,11.8,2.4,9.4,0
 Strawberry,32,0.7,0.3,7.7,2,4.9,1
 Blueberry,57,0.7,0.3,14.5,2.4,9.9,1
+Raspberry,52,1.2,0.7,11.9,6.5,4.4,1
+Blackberry,43,1.4,0.5,9.6,5.3,4.9,1
+Mango,60,0.8,0.4,15,1.6,13.7,1
+Pineapple,50,0.5,0.1,13.1,1.4,9.9,1
+Watermelon,30,0.6,0.2,7.6,0.4,6.2,1
+Grapes,69,0.7,0.2,18.1,0.9,15.5,2
+Peach,39,0.9,0.3,9.5,1.5,8.4,0
+Pear,57,0.4,0.1,15.2,3.1,9.8,1
+Kiwi,61,1.1,0.5,14.7,3,9,3
 Avocado,160,2,14.7,8.5,6.7,0.7,7
+Lemon,29,1.1,0.3,9.3,2.8,2.5,2
+Lime,30,0.7,0.2,10.5,2.8,1.7,2
+Coconut (Raw),354,3.3,33.5,15.2,9,6.2,20
 Almonds,579,21.2,49.9,21.7,12.5,4.4,1
 Walnuts,654,15.2,65.2,13.7,6.7,2.6,2
+Cashews,553,18.2,43.9,30.2,3.3,5.9,12
+Peanuts,567,25.8,49.2,16.1,8.5,4.7,18
+Pistachios,562,20.2,45.4,27.7,10.3,7.7,0
+Pumpkin Seeds,559,30.2,49,10.7,6,1.4,7
+Sunflower Seeds,584,20.8,51.5,20,8.6,2.6,3
+Chia Seeds,486,16.5,30.7,42.1,34.4,0,16
+Flaxseeds,534,18.3,42.2,28.9,27.3,1.5,30
+Hemp Seeds,553,31.6,48.7,8.7,4,1.5,5
 Peanut Butter,588,25.1,50.4,20,6,9.9,17
+Almond Butter,614,21,55.5,18.8,10.3,4.4,2
 Olive Oil,884,0,100,0,0,0,2
+Coconut Oil,862,0,100,0,0,0,0
 Butter,717,0.8,81.1,0.1,0,0.1,11
 Whole Milk,61,3.2,3.3,4.8,0,5.1,43
+Skimmed Milk,34,3.4,0.1,4.9,0,5.1,44
+Soy Milk,33,2.9,1.8,1.7,0.1,0.3,41
+Almond Milk,13,0.4,1,0.3,0.3,0,61
 Greek Yogurt (Plain),59,10.3,0.4,3.6,0,3.2,36
+Yogurt (Natural),61,3.5,3.3,4.7,0,4.7,46
 Cheddar Cheese,403,24.9,33.1,1.3,0,0.5,621
-Bacon (Cooked),541,37,42,1.4,0,0,1717
+Mozzarella,280,28.1,17,2.2,0,1,16
+Parmesan,431,38.5,28.6,4.1,0,0.8,1529
+Cottage Cheese,98,11.1,4.3,3.4,0,2.7,364
+Cream Cheese,342,5.9,34.2,4.1,0,2.7,321
 Bread (White),266,8.9,3.3,50.6,2.7,4.3,491
 Bread (Whole Wheat),247,11,3.4,42.7,7,6.2,400
+Sourdough Bread,289,8.5,1.6,58.1,1.5,1.6,571
+Tortilla (Flour),312,7.9,7.2,49.7,2.5,2.3,630
+Crackers (Whole Wheat),432,11,14,68.5,7.8,2.7,723
+Granola,471,10.3,19.8,64.1,5.6,21.9,31
+Cornflakes,357,8,0.8,79.9,2,7.7,802
+Oatmeal (Cooked),68,2.4,1.4,12,2,0.5,49
+Chocolate (Dark 70%),598,7.8,42.6,45.9,10.9,24,20
+Honey,304,0.3,0,82.4,0.2,82.1,4
+Sugar,387,0,0,100,0,100,1
+Olive (Black),116,0.8,10.9,6.3,3.2,0,735
+Hummus,177,7.9,9.6,14.3,6,0.5,379
+Salsa,36,1.8,0.1,7.8,2,4.3,479
+Ketchup,101,1.4,0.2,26.1,0.3,22.4,907
+Mayonnaise,680,0.9,75,0.6,0,0.5,635
+Mustard,66,3.7,3.7,5.3,3.7,0.9,1135
+Soy Sauce,53,8.1,0.1,4.9,0.8,0.9,5493

+ 7 - 3
seed_food_db.py

@@ -3,6 +3,11 @@ import sqlite3
 import urllib.request
 import os
 import csv
+import sys
+
+# Ensure the app directory is on the path so we can import database.py
+sys.path.insert(0, os.path.dirname(__file__))
+from database import create_tables
 
 DB_PATH = os.path.join(os.path.dirname(__file__), "localfood.db")
 
@@ -12,9 +17,8 @@ def get_db_connection():
     return conn
 
 def fetch_and_seed():
-    ctx = ssl.create_default_context()
-    ctx.check_hostname = False
-    ctx.verify_mode = ssl.CERT_NONE
+    # Always ensure the schema exists before inserting
+    create_tables()
 
     print("Loading fundamental internal CSV dataset...")
     csv_path = os.path.join(os.path.dirname(__file__), "nutrition.csv")

+ 8 - 0
verify_search.py

@@ -0,0 +1,8 @@
+import os
+os.chdir('/home/roni/LocalFoodAI')
+from database import search_foods_by_name
+
+for query in ['tuna', 'sal', 'chi', 'xyz', 'egg', 'broc']:
+    matches = search_foods_by_name(query)
+    names = [m['name'] for m in matches]
+    print(f"[{query:6}] -> {names[:4] if names else 'NO RESULTS'}")