esilver commited on
Commit
0ce15ef
·
1 Parent(s): cefdb5c

Fixed comparison bug

Browse files
Files changed (1) hide show
  1. comparison.py +6 -17
comparison.py CHANGED
@@ -2,8 +2,7 @@ import json
2
  import numpy as np
3
  from typing import Dict, List, Tuple, Any
4
 
5
- from ui_hybrid_matching import hybrid_category_matching_voyage
6
- # from category_matching import hybrid_category_matching
7
  from similarity import hybrid_ingredient_matching
8
 
9
  from api_utils import process_in_parallel, rank_ingredients_openai
@@ -96,16 +95,10 @@ def compare_ingredient_methods(products: List[str], ingredients_dict: Dict[str,
96
  chicory_data = chicory_results[product]
97
  if isinstance(chicory_data, dict):
98
  # Handle different response formats based on match type
99
- if match_type == "ingredients":
100
- ingredient = chicory_data.get("ingredient", "")
101
- confidence = chicory_data.get("confidence", 0)
102
- if ingredient and confidence >= confidence_threshold:
103
- chicory_matches.append((ingredient, confidence))
104
- else: # categories
105
- category = chicory_data.get("category", "")
106
- confidence = chicory_data.get("confidence", 0)
107
- if category and confidence >= confidence_threshold:
108
- chicory_matches.append((category, confidence))
109
 
110
  comparison_results[product]["chicory"] = chicory_matches
111
 
@@ -147,11 +140,7 @@ def compare_ingredient_methods(products: List[str], ingredients_dict: Dict[str,
147
  else:
148
  # Convert candidates to the expected format
149
  candidate_dict = {c[0]: c[0] for c in candidates}
150
- print(f"Voyage AI category matching for {product} with {len(candidate_dict)} categories")
151
- print(f"Expanded description: {expanded_descriptions.get(product, '')}")
152
- print(f"Expanded product: {expanded_product_desc.get(product, '')}")
153
- print(f"Categories: {candidate_dict}")
154
- results = hybrid_category_matching_voyage(
155
  products=[product],
156
  categories=candidate_dict,
157
  embedding_top_n=embedding_top_n,
 
2
  import numpy as np
3
  from typing import Dict, List, Tuple, Any
4
 
5
+ from category_matching import hybrid_category_matching
 
6
  from similarity import hybrid_ingredient_matching
7
 
8
  from api_utils import process_in_parallel, rank_ingredients_openai
 
95
  chicory_data = chicory_results[product]
96
  if isinstance(chicory_data, dict):
97
  # Handle different response formats based on match type
98
+ ingredient = chicory_data.get("ingredient", "")
99
+ confidence = chicory_data.get("confidence", 0)
100
+ if ingredient and confidence >= confidence_threshold:
101
+ chicory_matches.append((ingredient, confidence))
 
 
 
 
 
 
102
 
103
  comparison_results[product]["chicory"] = chicory_matches
104
 
 
140
  else:
141
  # Convert candidates to the expected format
142
  candidate_dict = {c[0]: c[0] for c in candidates}
143
+ results = hybrid_category_matching(
 
 
 
 
144
  products=[product],
145
  categories=candidate_dict,
146
  embedding_top_n=embedding_top_n,