feat: inclure l'unité/poids dans la normalisation LLM
fetch_unnormalized() remonte maintenant la colonne `unit` (ex: "250 g", "20 sachets"). Le normaliseur concatène name_raw + unit avant d'envoyer au LLM, qui peut ainsi placer le poids dans le champ format. Résultat : "Haribo dragibus" → "Dragibus | Haribo | 250g" au lieu de "Haribo dragibus" → "Dragibus | Haribo | -" Améliore aussi la qualité du fuzzy matching Picnic ↔ Leclerc. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -229,7 +229,13 @@ def normalize_all_in_db(
|
||||
|
||||
for start in range(0, total, batch_size):
|
||||
batch = items[start: start + batch_size]
|
||||
raw_names = [row["name_raw"] for row in batch]
|
||||
# On inclut l'unité/poids (ex: "250 g", "20 sachets") dans le nom
|
||||
# envoyé au LLM pour qu'il puisse le placer dans le champ format.
|
||||
# Pour les articles sans unité (Leclerc OCR), unit est None ou "".
|
||||
raw_names = [
|
||||
f"{row['name_raw']} {row['unit']}".strip() if row["unit"] else row["name_raw"]
|
||||
for row in batch
|
||||
]
|
||||
|
||||
# --- Tentative batch ---
|
||||
try:
|
||||
@@ -246,7 +252,7 @@ def normalize_all_in_db(
|
||||
# tente le fallback un par un
|
||||
if all(r is None for r in results):
|
||||
logger.debug("Fallback unitaire pour le batch %d–%d.", start, start + len(batch))
|
||||
results = [normalize_product_name(name) for name in raw_names]
|
||||
results = [normalize_product_name(name) for name in raw_names] # raw_names contient déjà l'unité
|
||||
|
||||
# --- Mise à jour ou affichage ---
|
||||
for item, normalized in zip(batch, results):
|
||||
|
||||
Reference in New Issue
Block a user