SamiKoen commited on
Commit
62d4760
·
1 Parent(s): bd6013c

Beden eşleştirme algoritması iyileştirildi

Browse files

- Varyant tokenları hem tire hem boşlukla ayrılıyor (s-beyaz gri formatı için)
- normalize_turkish fonksiyonu iyileştirildi (noktalı i karakteri için)
- Beden eşleşmesi için startswith kontrolü eklendi
- Artık S beden sadece Caddebostan'da gösterilecek

Files changed (2) hide show
  1. __pycache__/app.cpython-312.pyc +0 -0
  2. app.py +16 -7
__pycache__/app.cpython-312.pyc CHANGED
Binary files a/__pycache__/app.cpython-312.pyc and b/__pycache__/app.cpython-312.pyc differ
 
app.py CHANGED
@@ -58,14 +58,18 @@ def get_warehouse_stock(product_name):
58
 
59
  def normalize_turkish(text):
60
  import unicodedata
61
- text = unicodedata.normalize('NFD', text)
 
62
  text = ''.join(char for char in text if unicodedata.category(char) != 'Mn')
 
63
  for tr_char, en_char in turkish_map.items():
64
  text = text.replace(tr_char, en_char)
65
- return text
 
 
66
 
67
  # Normalize search product name
68
- search_name = normalize_turkish(product_name.lower().strip())
69
  search_name = search_name.replace('(2026)', '').replace('(2025)', '').replace(' gen 3', '').replace(' gen', '').strip()
70
  search_words = search_name.split()
71
 
@@ -103,11 +107,11 @@ def get_warehouse_stock(product_name):
103
 
104
  if product_name_elem is not None and product_name_elem.text:
105
  xml_product_name = product_name_elem.text.strip()
106
- normalized_name = normalize_turkish(xml_product_name.lower())
107
 
108
  variant_text = ""
109
  if variant_elem is not None and variant_elem.text:
110
- variant_text = normalize_turkish(variant_elem.text.strip().lower())
111
 
112
  # Context-aware matching
113
  name_match = False
@@ -124,8 +128,13 @@ def get_warehouse_stock(product_name):
124
  # For single letter sizes (S, M, L, etc), require exact match
125
  if len(variant_words) == 1 and len(variant_words[0]) <= 2:
126
  # Check if size appears as a separate token in variant
127
- variant_tokens = variant_text.split('-')
128
- variant_match = any(variant_words[0] == token.strip() for token in variant_tokens)
 
 
 
 
 
129
  else:
130
  variant_match = all(word in variant_text for word in variant_words)
131
  elif variant_words and not variant_text:
 
58
 
59
  def normalize_turkish(text):
60
  import unicodedata
61
+ # First normalize unicode to handle combining characters
62
+ text = unicodedata.normalize('NFKD', text)
63
  text = ''.join(char for char in text if unicodedata.category(char) != 'Mn')
64
+ # Replace Turkish characters
65
  for tr_char, en_char in turkish_map.items():
66
  text = text.replace(tr_char, en_char)
67
+ # Also handle dotted i (İ with dot above)
68
+ text = text.replace('İ', 'i').replace('I', 'i')
69
+ return text.lower()
70
 
71
  # Normalize search product name
72
+ search_name = normalize_turkish(product_name.strip())
73
  search_name = search_name.replace('(2026)', '').replace('(2025)', '').replace(' gen 3', '').replace(' gen', '').strip()
74
  search_words = search_name.split()
75
 
 
107
 
108
  if product_name_elem is not None and product_name_elem.text:
109
  xml_product_name = product_name_elem.text.strip()
110
+ normalized_name = normalize_turkish(xml_product_name)
111
 
112
  variant_text = ""
113
  if variant_elem is not None and variant_elem.text:
114
+ variant_text = normalize_turkish(variant_elem.text.strip())
115
 
116
  # Context-aware matching
117
  name_match = False
 
128
  # For single letter sizes (S, M, L, etc), require exact match
129
  if len(variant_words) == 1 and len(variant_words[0]) <= 2:
130
  # Check if size appears as a separate token in variant
131
+ # Split by both dash and space to handle "s-beyaz gri" format
132
+ variant_tokens = variant_text.replace('-', ' ').split()
133
+ variant_match = any(variant_words[0] == token.strip().lower() for token in variant_tokens)
134
+
135
+ # Also check if it starts with the size (e.g., "s-beyaz")
136
+ if not variant_match:
137
+ variant_match = variant_text.startswith(variant_words[0] + '-') or variant_text.startswith(variant_words[0] + ' ')
138
  else:
139
  variant_match = all(word in variant_text for word in variant_words)
140
  elif variant_words and not variant_text: