Spaces:
Paused
Paused
Commit
•
bbe1fe8
1
Parent(s):
b1c94e2
bugfixes
Browse files
algo.py
CHANGED
@@ -5,7 +5,7 @@ from pluralizer import Pluralizer
|
|
5 |
from similarity_fast import SimilarityFast
|
6 |
from food_nonfood import classify_as_food_nonfood, pessimistic_food_nonfood_score
|
7 |
from utils import clean_word
|
8 |
-
from db.db_utils import store_mapping_to_db, get_mapping_from_db
|
9 |
from ask_gpt import query_gpt
|
10 |
from multi_food_item_detector import extract_items
|
11 |
|
@@ -175,7 +175,7 @@ class Algo:
|
|
175 |
|
176 |
# try the singular form of the word
|
177 |
singular = self.pluralizer.pluralize(input_word_clean, 1)
|
178 |
-
mapping = wrap_mapping_with_dictionary_data(get_mapping_from_db(self.db_cursor, singular))
|
179 |
if mapping:
|
180 |
print(f" - Found mapping in db: {mapping}")
|
181 |
return mapping
|
@@ -204,7 +204,7 @@ class Algo:
|
|
204 |
'food_nonfood_score': food_nonfood[1]
|
205 |
}
|
206 |
store_mapping_to_db(self.db_cursor, self.db_conn, mapping)
|
207 |
-
return wrap_mapping_with_dictionary_data(mapping)
|
208 |
|
209 |
mapping = self.perform_mapping(input_word)
|
210 |
|
@@ -217,7 +217,7 @@ class Algo:
|
|
217 |
print(f" - Storing new mapping to db: {mapping}")
|
218 |
store_mapping_to_db(self.db_cursor, self.db_conn, mapping)
|
219 |
|
220 |
-
return wrap_mapping_with_dictionary_data(mapping)
|
221 |
|
222 |
def wrap_mapping_with_dictionary_data(self, mapping):
|
223 |
dictionary_result = get_dictionary_data_from_db(self.db_cursor, mapping['dictionary_word'])
|
|
|
5 |
from similarity_fast import SimilarityFast
|
6 |
from food_nonfood import classify_as_food_nonfood, pessimistic_food_nonfood_score
|
7 |
from utils import clean_word
|
8 |
+
from db.db_utils import store_mapping_to_db, get_mapping_from_db, get_dictionary_data_from_db
|
9 |
from ask_gpt import query_gpt
|
10 |
from multi_food_item_detector import extract_items
|
11 |
|
|
|
175 |
|
176 |
# try the singular form of the word
|
177 |
singular = self.pluralizer.pluralize(input_word_clean, 1)
|
178 |
+
mapping = self.wrap_mapping_with_dictionary_data(get_mapping_from_db(self.db_cursor, singular))
|
179 |
if mapping:
|
180 |
print(f" - Found mapping in db: {mapping}")
|
181 |
return mapping
|
|
|
204 |
'food_nonfood_score': food_nonfood[1]
|
205 |
}
|
206 |
store_mapping_to_db(self.db_cursor, self.db_conn, mapping)
|
207 |
+
return self.wrap_mapping_with_dictionary_data(mapping)
|
208 |
|
209 |
mapping = self.perform_mapping(input_word)
|
210 |
|
|
|
217 |
print(f" - Storing new mapping to db: {mapping}")
|
218 |
store_mapping_to_db(self.db_cursor, self.db_conn, mapping)
|
219 |
|
220 |
+
return self.wrap_mapping_with_dictionary_data(mapping)
|
221 |
|
222 |
def wrap_mapping_with_dictionary_data(self, mapping):
|
223 |
dictionary_result = get_dictionary_data_from_db(self.db_cursor, mapping['dictionary_word'])
|