SamiKoen Claude commited on
Commit
d3d2c20
·
1 Parent(s): 2a09017

Soru kelimelerini filtrele ve rakamları koru

Browse files

- 'var mı', 'stokta mı' gibi soru kelimelerini ignore et
- Rakamları koru (6, 7, 8)
- 'gen 8' gibi ifadeleri birleştir
- 'trek' kelimesini filtrele

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

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

Files changed (1) hide show
  1. app.py +19 -1
app.py CHANGED
@@ -53,10 +53,28 @@ def get_warehouse_stock(product_name):
53
  query = normalize(product_name.strip()).replace('(2026)', '').replace('(2025)', '').strip()
54
  words = query.split()
55
 
 
 
 
 
 
56
  # Find size
57
  sizes = ['s', 'm', 'l', 'xl', 'xs', 'xxl', 'ml']
58
  size = next((w for w in words if w in sizes), None)
59
- product_words = [w for w in words if w not in sizes and w not in ['beden', 'size', 'boy']]
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
  print(f"DEBUG - Searching: {' '.join(product_words)}, Size: {size}")
62
 
 
53
  query = normalize(product_name.strip()).replace('(2026)', '').replace('(2025)', '').strip()
54
  words = query.split()
55
 
56
+ # Words to ignore in product search
57
+ ignore_words = ['var', 'mi', 'mı', 'mu', 'mü', 'varmi', 'varmı', 'beden', 'size', 'boy',
58
+ 'stok', 'stokta', 'mevcut', 'hangi', 'magazada', 'nerede', 'kaç', 'adet', 'tane',
59
+ 'trek', 'bisiklet', 'bike']
60
+
61
  # Find size
62
  sizes = ['s', 'm', 'l', 'xl', 'xs', 'xxl', 'ml']
63
  size = next((w for w in words if w in sizes), None)
64
+
65
+ # Filter product words - remove sizes and question words
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