Spaces:
Running
on
Zero
Running
on
Zero
do not use synonyms
Browse files
app.py
CHANGED
|
@@ -313,7 +313,7 @@ def extract_notes_for_comparison(data: Union[str, dict]) -> list[str]:
|
|
| 313 |
|
| 314 |
olfactory_pyramid = data.get("Olfactory Pyramid") or data.get("olfactory pyramid")
|
| 315 |
if not olfactory_pyramid:
|
| 316 |
-
return [] #
|
| 317 |
|
| 318 |
notes = []
|
| 319 |
for layer in ["Top Notes", "Heart Notes", "Base Notes"]:
|
|
@@ -333,7 +333,7 @@ from rapidfuzz import fuzz
|
|
| 333 |
def find_best_perfumes_from_json(data: Union[str, dict], top_n: int = 5, threshold: int = 80):
|
| 334 |
"""
|
| 335 |
Finds top N matching perfumes using fuzzy matching on notes.
|
| 336 |
-
If no notes found, returns an
|
| 337 |
"""
|
| 338 |
user_notes = extract_notes_for_comparison(data)
|
| 339 |
if not user_notes:
|
|
@@ -345,7 +345,8 @@ def find_best_perfumes_from_json(data: Union[str, dict], top_n: int = 5, thresho
|
|
| 345 |
'similarity_score': 0
|
| 346 |
}])
|
| 347 |
|
| 348 |
-
|
|
|
|
| 349 |
|
| 350 |
matches = []
|
| 351 |
for _, row in df.iterrows():
|
|
|
|
| 313 |
|
| 314 |
olfactory_pyramid = data.get("Olfactory Pyramid") or data.get("olfactory pyramid")
|
| 315 |
if not olfactory_pyramid:
|
| 316 |
+
return [] # Safe fallback
|
| 317 |
|
| 318 |
notes = []
|
| 319 |
for layer in ["Top Notes", "Heart Notes", "Base Notes"]:
|
|
|
|
| 333 |
def find_best_perfumes_from_json(data: Union[str, dict], top_n: int = 5, threshold: int = 80):
|
| 334 |
"""
|
| 335 |
Finds top N matching perfumes using fuzzy matching on notes.
|
| 336 |
+
If no notes found or no matches, returns an informative result.
|
| 337 |
"""
|
| 338 |
user_notes = extract_notes_for_comparison(data)
|
| 339 |
if not user_notes:
|
|
|
|
| 345 |
'similarity_score': 0
|
| 346 |
}])
|
| 347 |
|
| 348 |
+
# Lowercase user notes
|
| 349 |
+
user_notes_clean = [n.strip().lower() for n in user_notes]
|
| 350 |
|
| 351 |
matches = []
|
| 352 |
for _, row in df.iterrows():
|