Spaces:
Paused
Paused
Commit
•
f0a2141
1
Parent(s):
fd50ca7
updated category_mapper to handle when nothing is available
Browse files- category_mapper.py +12 -13
category_mapper.py
CHANGED
@@ -23,8 +23,8 @@ file_path = './dictionary/final_corrected_wweia_food_category_complete - final_c
|
|
23 |
spreadsheet = pd.read_csv(file_path)
|
24 |
|
25 |
def find_best_category(food_item, category, dataframe):
|
26 |
-
|
27 |
-
filtered_df = dataframe[dataframe['closest_category'] == category]
|
28 |
if not filtered_df.empty:
|
29 |
descriptions = filtered_df['wweia_food_category_description'].tolist()
|
30 |
|
@@ -32,7 +32,6 @@ def find_best_category(food_item, category, dataframe):
|
|
32 |
f"Given the food item '{food_item}' and the category '{category}', choose the most appropriate category from the following options:\n{descriptions}\n\n"
|
33 |
f"You should respond in json format with an object that has the key `guess`, and the value is the categoy."
|
34 |
)
|
35 |
-
|
36 |
completion = client.chat.completions.create(
|
37 |
messages=[
|
38 |
{"role": "system", "content": "You are a helpful assistant."},
|
@@ -67,16 +66,16 @@ for row in tqdm(rows, desc="Processing"):
|
|
67 |
# fix the category for Breakfast Cereals
|
68 |
if category == 'Breakfast Cereals':
|
69 |
category = 'Cereal Grains and Pasta'
|
70 |
-
elif category == 'Fast Foods':
|
71 |
-
|
72 |
-
elif category == 'American Indian/Alaska Native Foods':
|
73 |
-
|
74 |
-
elif category == 'Restaurant Foods':
|
75 |
-
|
76 |
-
elif category == 'Spices and Herbs':
|
77 |
-
|
78 |
-
elif category == 'Restaurant Foods':
|
79 |
-
|
80 |
|
81 |
if pd.notna(row['wweia_category']) and row['wweia_category'] != "" and row['wweia_category'] != "nan" and row is not None:
|
82 |
# print(f"Skipping '{food_item}' as it already has a category {row['wweia_category']}")
|
|
|
23 |
spreadsheet = pd.read_csv(file_path)
|
24 |
|
25 |
def find_best_category(food_item, category, dataframe):
|
26 |
+
filtered_df = dataframe
|
27 |
+
# filtered_df = dataframe[dataframe['closest_category'] == category]
|
28 |
if not filtered_df.empty:
|
29 |
descriptions = filtered_df['wweia_food_category_description'].tolist()
|
30 |
|
|
|
32 |
f"Given the food item '{food_item}' and the category '{category}', choose the most appropriate category from the following options:\n{descriptions}\n\n"
|
33 |
f"You should respond in json format with an object that has the key `guess`, and the value is the categoy."
|
34 |
)
|
|
|
35 |
completion = client.chat.completions.create(
|
36 |
messages=[
|
37 |
{"role": "system", "content": "You are a helpful assistant."},
|
|
|
66 |
# fix the category for Breakfast Cereals
|
67 |
if category == 'Breakfast Cereals':
|
68 |
category = 'Cereal Grains and Pasta'
|
69 |
+
# elif category == 'Fast Foods':
|
70 |
+
# # TODO
|
71 |
+
# elif category == 'American Indian/Alaska Native Foods':
|
72 |
+
# # TODO
|
73 |
+
# elif category == 'Restaurant Foods':
|
74 |
+
# # TODO
|
75 |
+
# elif category == 'Spices and Herbs':
|
76 |
+
# # TODO
|
77 |
+
# elif category == 'Restaurant Foods':
|
78 |
+
# # TODO
|
79 |
|
80 |
if pd.notna(row['wweia_category']) and row['wweia_category'] != "" and row['wweia_category'] != "nan" and row is not None:
|
81 |
# print(f"Skipping '{food_item}' as it already has a category {row['wweia_category']}")
|