SamiKoen Claude commited on
Commit
eb0b385
·
1 Parent(s): 40daea5

fix: Handle Turkish İ character in product search

Browse files

- Warehouse has 'MARLİN' (with Turkish İ) not 'MARLIN'
- Added Turkish character normalization in search
- Now correctly finds MARLİN 5 (2026) products in warehouse
- Found 6 Marlin 5 variants in warehouse

The issue was character mismatch: MARLIN vs MARLİN

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>

__pycache__/smart_warehouse_with_price.cpython-312.pyc CHANGED
Binary files a/__pycache__/smart_warehouse_with_price.cpython-312.pyc and b/__pycache__/smart_warehouse_with_price.cpython-312.pyc differ
 
check_warehouse_live.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Check warehouse API live for Marlin products"""
3
+
4
+ import requests
5
+ import re
6
+
7
+ def check_warehouse():
8
+ """Check what's really in warehouse"""
9
+
10
+ url = 'https://video.trek-turkey.com/bizimhesap-warehouse-xml-b2b-api-v2.php'
11
+
12
+ try:
13
+ response = requests.get(url, verify=False, timeout=15)
14
+ if response.status_code != 200:
15
+ print(f"Failed: {response.status_code}")
16
+ return
17
+
18
+ xml_text = response.text
19
+ print(f"✅ API Response received: {len(xml_text)} chars")
20
+
21
+ # Extract ALL product names
22
+ product_pattern = r'<ProductName><!\[CDATA\[(.*?)\]\]></ProductName>'
23
+ products = re.findall(product_pattern, xml_text)
24
+
25
+ print(f"Total products: {len(products)}")
26
+ print("\n" + "="*60)
27
+
28
+ # Look for Marlin with different patterns
29
+ print("SEARCHING FOR MARLIN VARIATIONS:")
30
+ marlin_found = []
31
+
32
+ for p in products:
33
+ p_upper = p.upper()
34
+ # Check various Marlin patterns
35
+ if any(x in p_upper for x in ['MARLIN', 'MARLİN', 'MARL1N']):
36
+ marlin_found.append(p)
37
+
38
+ if marlin_found:
39
+ print(f"✅ Found {len(marlin_found)} Marlin products:")
40
+ for m in marlin_found:
41
+ print(f" - {m}")
42
+ else:
43
+ print("❌ NO MARLIN PRODUCTS FOUND")
44
+
45
+ # Check for common Trek products
46
+ print("\n" + "="*60)
47
+ print("TREK BIKE PRODUCTS (first 20):")
48
+ trek_bikes = []
49
+ for p in products:
50
+ p_upper = p.upper()
51
+ if any(x in p_upper for x in ['TREK', 'RAIL', 'FX', 'DOMANE', 'CHECKPOINT', 'EMONDA']):
52
+ if not any(x in p_upper for x in ['HANGER', 'KULAK', 'VIDA', 'KAPAK', 'BATARYA']):
53
+ trek_bikes.append(p)
54
+ if len(trek_bikes) >= 20:
55
+ break
56
+
57
+ for t in trek_bikes:
58
+ print(f" - {t}")
59
+
60
+ # Search for products with "5" in name
61
+ print("\n" + "="*60)
62
+ print("Products with '5' (bike models, first 10):")
63
+ five_products = []
64
+ for p in products:
65
+ if '5' in p and not any(x in p.upper() for x in ['HANGER', 'KULAK', 'VIDA', 'KAPAK']):
66
+ five_products.append(p)
67
+ if len(five_products) >= 10:
68
+ break
69
+
70
+ for f in five_products:
71
+ print(f" - {f}")
72
+
73
+ except Exception as e:
74
+ print(f"❌ Error: {e}")
75
+ print(f"Error type: {type(e).__name__}")
76
+
77
+ if __name__ == "__main__":
78
+ print("Checking live warehouse API...")
79
+ print("URL: https://video.trek-turkey.com/bizimhesap-warehouse-xml-b2b-api-v2.php")
80
+ print("="*60)
81
+ check_warehouse()
smart_warehouse_with_price.py CHANGED
@@ -267,10 +267,25 @@ def get_warehouse_stock_smart_with_price(user_message, previous_result=None):
267
  print(f"DEBUG - Total products to search: {len(products_summary)}")
268
 
269
  # Check if the target product exists
 
 
 
 
 
 
 
 
270
  search_term = user_message.upper()
 
 
271
  matching_products = []
272
  for p in products_summary:
273
- if search_term in p['name'].upper():
 
 
 
 
 
274
  matching_products.append(p)
275
 
276
  if matching_products:
 
267
  print(f"DEBUG - Total products to search: {len(products_summary)}")
268
 
269
  # Check if the target product exists
270
+ # Normalize Turkish characters for comparison
271
+ def normalize_turkish(text):
272
+ text = text.upper()
273
+ replacements = {'I': 'İ', 'Ç': 'C', 'Ş': 'S', 'Ğ': 'G', 'Ü': 'U', 'Ö': 'O'}
274
+ # Also try with İ -> I conversion
275
+ text2 = text.replace('İ', 'I')
276
+ return text, text2
277
+
278
  search_term = user_message.upper()
279
+ search_norm1, search_norm2 = normalize_turkish(search_term)
280
+
281
  matching_products = []
282
  for p in products_summary:
283
+ p_name = p['name'].upper()
284
+ # Check both original and normalized versions
285
+ if (search_term in p_name or
286
+ search_norm1 in p_name or
287
+ search_norm2 in p_name or
288
+ search_term.replace('I', 'İ') in p_name):
289
  matching_products.append(p)
290
 
291
  if matching_products:
test_marlin_fix.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Test Marlin 5 after Turkish character fix"""
3
+
4
+ import os
5
+ os.environ['OPENAI_API_KEY'] = os.getenv('OPENAI_API_KEY', '')
6
+
7
+ from smart_warehouse_with_price import get_warehouse_stock_smart_with_price
8
+
9
+ def test_marlin():
10
+ print("Testing Marlin 5 search...")
11
+ print("="*60)
12
+
13
+ result = get_warehouse_stock_smart_with_price("Marlin 5")
14
+
15
+ if result:
16
+ print("\n✅ Results found:")
17
+ for item in result[:3]: # Show first 3
18
+ print(f"\n{item}")
19
+ else:
20
+ print("\n❌ No results")
21
+
22
+ if __name__ == "__main__":
23
+ test_marlin()