fix: Fix Turkish char normalization order in all files
Browse files- Must normalize BEFORE lower() to handle İ→i correctly
- Fixed in: warehouse_stock_finder, smart_warehouse_complete, smart_warehouse_whatsapp
- Added all Turkish uppercase chars to maps
Without this fix, 'MARLİN' would become 'marlin' and İ would be lost.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
__pycache__/warehouse_stock_finder.cpython-312.pyc
ADDED
|
Binary file (4.19 kB). View file
|
|
|
smart_warehouse_complete.py
CHANGED
|
@@ -18,15 +18,19 @@ def get_product_price_and_link(product_name, variant=None):
|
|
| 18 |
|
| 19 |
root = ET.fromstring(response.content)
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
|
| 23 |
-
search_variant = variant.lower() if variant else ""
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
|
|
|
|
| 27 |
for tr, en in tr_map.items():
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
best_match = None
|
| 32 |
best_score = 0
|
|
|
|
| 18 |
|
| 19 |
root = ET.fromstring(response.content)
|
| 20 |
|
| 21 |
+
# Turkish character normalization FIRST (before lower)
|
| 22 |
+
tr_map = {'İ': 'i', 'I': 'i', 'ı': 'i', 'Ğ': 'g', 'ğ': 'g', 'Ü': 'u', 'ü': 'u', 'Ş': 's', 'ş': 's', 'Ö': 'o', 'ö': 'o', 'Ç': 'c', 'ç': 'c'}
|
|
|
|
| 23 |
|
| 24 |
+
# Apply normalization to original
|
| 25 |
+
search_name_norm = product_name
|
| 26 |
+
search_variant_norm = variant if variant else ""
|
| 27 |
for tr, en in tr_map.items():
|
| 28 |
+
search_name_norm = search_name_norm.replace(tr, en)
|
| 29 |
+
search_variant_norm = search_variant_norm.replace(tr, en)
|
| 30 |
+
|
| 31 |
+
# Now lowercase
|
| 32 |
+
search_name = search_name_norm.lower()
|
| 33 |
+
search_variant = search_variant_norm.lower()
|
| 34 |
|
| 35 |
best_match = None
|
| 36 |
best_score = 0
|
smart_warehouse_whatsapp.py
CHANGED
|
@@ -17,15 +17,19 @@ def get_product_price_and_link(product_name, variant=None):
|
|
| 17 |
|
| 18 |
root = ET.fromstring(response.content)
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
|
| 22 |
-
search_variant = variant.lower() if variant else ""
|
| 23 |
|
| 24 |
-
#
|
| 25 |
-
|
|
|
|
| 26 |
for tr, en in tr_map.items():
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
best_match = None
|
| 31 |
best_score = 0
|
|
|
|
| 17 |
|
| 18 |
root = ET.fromstring(response.content)
|
| 19 |
|
| 20 |
+
# Turkish character normalization FIRST (before lower)
|
| 21 |
+
tr_map = {'İ': 'i', 'I': 'i', 'ı': 'i', 'Ğ': 'g', 'ğ': 'g', 'Ü': 'u', 'ü': 'u', 'Ş': 's', 'ş': 's', 'Ö': 'o', 'ö': 'o', 'Ç': 'c', 'ç': 'c'}
|
|
|
|
| 22 |
|
| 23 |
+
# Apply normalization to original
|
| 24 |
+
search_name_norm = product_name
|
| 25 |
+
search_variant_norm = variant if variant else ""
|
| 26 |
for tr, en in tr_map.items():
|
| 27 |
+
search_name_norm = search_name_norm.replace(tr, en)
|
| 28 |
+
search_variant_norm = search_variant_norm.replace(tr, en)
|
| 29 |
+
|
| 30 |
+
# Now lowercase
|
| 31 |
+
search_name = search_name_norm.lower()
|
| 32 |
+
search_variant = search_variant_norm.lower()
|
| 33 |
|
| 34 |
best_match = None
|
| 35 |
best_score = 0
|
warehouse_stock_finder.py
CHANGED
|
@@ -13,10 +13,12 @@ def get_warehouse_stock(product_name):
|
|
| 13 |
|
| 14 |
# Turkish normalize
|
| 15 |
def normalize(text):
|
| 16 |
-
tr_map = {'ı': 'i', 'ğ': 'g', 'ü': 'u', 'ş': 's', '
|
| 17 |
-
|
| 18 |
for tr, en in tr_map.items():
|
| 19 |
text = text.replace(tr, en)
|
|
|
|
|
|
|
| 20 |
return text
|
| 21 |
|
| 22 |
# Parse query
|
|
|
|
| 13 |
|
| 14 |
# Turkish normalize
|
| 15 |
def normalize(text):
|
| 16 |
+
tr_map = {'İ': 'i', 'I': 'i', 'ı': 'i', 'Ğ': 'g', 'ğ': 'g', 'Ü': 'u', 'ü': 'u', 'Ş': 's', 'ş': 's', 'Ö': 'o', 'ö': 'o', 'Ç': 'c', 'ç': 'c'}
|
| 17 |
+
# FIRST normalize Turkish chars
|
| 18 |
for tr, en in tr_map.items():
|
| 19 |
text = text.replace(tr, en)
|
| 20 |
+
# THEN lowercase
|
| 21 |
+
text = text.lower()
|
| 22 |
return text
|
| 23 |
|
| 24 |
# Parse query
|