beweinreich commited on
Commit
42e3a31
1 Parent(s): 8d827d2

add special case for usda

Browse files
Files changed (1) hide show
  1. algo.py +16 -1
algo.py CHANGED
@@ -33,6 +33,22 @@ class Algo:
33
  df_results.to_csv(output_file_path, index=False)
34
 
35
  def perform_mapping(self, input_word, attempts=0):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  mapping = self.similarity_fast.find_most_similar_word(input_word)
37
 
38
  # skip slow mapping for now
@@ -205,7 +221,6 @@ class Algo:
205
  if mapping:
206
  print(f" - Found mapping in db: {mapping}")
207
  return self.wrap_mapping_with_dictionary_data(mapping)
208
-
209
 
210
  food_nonfood = classify_as_food_nonfood(input_word)
211
 
 
33
  df_results.to_csv(output_file_path, index=False)
34
 
35
  def perform_mapping(self, input_word, attempts=0):
36
+
37
+ # if the input word is a USDA food item, we can skip the similarity check
38
+ # this is a special case because the USDA food items are Government Donation (Not Counted) items
39
+ if 'usda' in input_word.lower():
40
+ return {
41
+ 'input_word': input_word,
42
+ 'cleaned_word': clean_word(input_word),
43
+ 'matching_word': 'USDA Food Item',
44
+ 'dictionary_word': 'USDA Food Item',
45
+ 'similarity_score': 1.0,
46
+ 'confidence_score': 1.0,
47
+ 'similar_words': None,
48
+ 'is_food': True,
49
+ 'food_nonfood_score': 1.0
50
+ }
51
+
52
  mapping = self.similarity_fast.find_most_similar_word(input_word)
53
 
54
  # skip slow mapping for now
 
221
  if mapping:
222
  print(f" - Found mapping in db: {mapping}")
223
  return self.wrap_mapping_with_dictionary_data(mapping)
 
224
 
225
  food_nonfood = classify_as_food_nonfood(input_word)
226