Beden algılama düzeltmesi - M harfi değil M beden aranacak
Browse files
app.py
CHANGED
@@ -511,15 +511,39 @@ def chatbot_fn(user_message, history, image=None):
|
|
511 |
if not stock_info:
|
512 |
print(f"API'de '{product_name}' bulunamadı, XML'de aranıyor...")
|
513 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
514 |
# XML'deki products listesinde ara
|
515 |
found_product = None
|
516 |
for _, product_info, full_name in products:
|
517 |
full_name_lower = full_name.lower()
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
523 |
|
524 |
# Bulunan ürün adıyla API'yi tekrar çağır
|
525 |
if found_product:
|
|
|
511 |
if not stock_info:
|
512 |
print(f"API'de '{product_name}' bulunamadı, XML'de aranıyor...")
|
513 |
|
514 |
+
# Beden kontrolü - tek harfli kelimeler beden olabilir
|
515 |
+
size_words = ['s', 'm', 'l', 'xl', 'xxl', 'xs']
|
516 |
+
has_size = False
|
517 |
+
size_requested = None
|
518 |
+
|
519 |
+
for word in product_words:
|
520 |
+
if word.lower() in size_words:
|
521 |
+
has_size = True
|
522 |
+
size_requested = word.upper()
|
523 |
+
break
|
524 |
+
|
525 |
# XML'deki products listesinde ara
|
526 |
found_product = None
|
527 |
for _, product_info, full_name in products:
|
528 |
full_name_lower = full_name.lower()
|
529 |
+
|
530 |
+
# Beden belirtilmişse
|
531 |
+
if has_size and size_requested:
|
532 |
+
# Beden hariç diğer kelimeleri kontrol et
|
533 |
+
other_words = [w for w in product_words if w.lower() not in size_words]
|
534 |
+
# Diğer kelimeler ürün adında var mı?
|
535 |
+
if all(word in full_name_lower for word in other_words):
|
536 |
+
# Ve istenen beden tam olarak eşleşiyor mu? (M-KREM veya M - formatında)
|
537 |
+
if f' {size_requested} -' in full_name or f' {size_requested}-' in full_name:
|
538 |
+
found_product = full_name
|
539 |
+
print(f"XML'de beden eşleşmesi bulundu: {found_product}")
|
540 |
+
break
|
541 |
+
else:
|
542 |
+
# Beden belirtilmemişse normal arama
|
543 |
+
if all(word in full_name_lower for word in product_words):
|
544 |
+
found_product = full_name
|
545 |
+
print(f"XML'de eşleşen ürün bulundu: {found_product}")
|
546 |
+
break
|
547 |
|
548 |
# Bulunan ürün adıyla API'yi tekrar çağır
|
549 |
if found_product:
|