Tamamen genel algoritma - spesifik kelime yok
Browse files- 'gen 8' gibi özel durumlar için kod yok
- Genel kelime eşleştirme algoritması
- Sayıların kelimelerle birleşik veya ayrı olması durumunu handle et
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
app.py
CHANGED
@@ -66,16 +66,6 @@ def get_warehouse_stock(product_name):
|
|
66 |
# Keep numbers (like 6, 7, 8) and words longer than 1 char
|
67 |
product_words = [w for w in words if w not in sizes and w not in ignore_words and (len(w) > 1 or w.isdigit())]
|
68 |
|
69 |
-
# Handle "gen 8", "gen 7" patterns - keep them together
|
70 |
-
if 'gen' in product_words:
|
71 |
-
gen_index = product_words.index('gen')
|
72 |
-
if gen_index < len(product_words) - 1:
|
73 |
-
next_word = product_words[gen_index + 1]
|
74 |
-
if next_word.isdigit():
|
75 |
-
# Combine "gen" and number
|
76 |
-
product_words[gen_index] = f'gen {next_word}'
|
77 |
-
product_words.pop(gen_index + 1)
|
78 |
-
|
79 |
print(f"DEBUG - Searching: {' '.join(product_words)}, Size: {size}")
|
80 |
|
81 |
# Find all Product blocks in XML
|
@@ -96,8 +86,18 @@ def get_warehouse_stock(product_name):
|
|
96 |
product_name_in_xml = name_match.group(1)
|
97 |
normalized_xml_name = normalize(product_name_in_xml)
|
98 |
|
99 |
-
# Check if all product words are in the name
|
100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
# Product name matches, now check variant if needed
|
102 |
|
103 |
if size:
|
|
|
66 |
# Keep numbers (like 6, 7, 8) and words longer than 1 char
|
67 |
product_words = [w for w in words if w not in sizes and w not in ignore_words and (len(w) > 1 or w.isdigit())]
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
print(f"DEBUG - Searching: {' '.join(product_words)}, Size: {size}")
|
70 |
|
71 |
# Find all Product blocks in XML
|
|
|
86 |
product_name_in_xml = name_match.group(1)
|
87 |
normalized_xml_name = normalize(product_name_in_xml)
|
88 |
|
89 |
+
# Check if all product words are in the name (as separate words or part of words)
|
90 |
+
# This handles cases like "gen 8" where it might be "gen8" or "gen 8" in XML
|
91 |
+
match = True
|
92 |
+
for word in product_words:
|
93 |
+
# Check if word exists as-is or without spaces (for numbers after text)
|
94 |
+
if word not in normalized_xml_name:
|
95 |
+
# Also check if it's a number that might be attached to previous word
|
96 |
+
if not (word.isdigit() and any(f"{prev}{word}" in normalized_xml_name or f"{prev} {word}" in normalized_xml_name for prev in product_words if not prev.isdigit())):
|
97 |
+
match = False
|
98 |
+
break
|
99 |
+
|
100 |
+
if match:
|
101 |
# Product name matches, now check variant if needed
|
102 |
|
103 |
if size:
|