Spaces:
Sleeping
Sleeping
Commit
路
7ffbe71
1
Parent(s):
38350ae
new r + stee product expansion
Browse files
utils.py
CHANGED
|
@@ -212,26 +212,34 @@ STEEL_PRODUCT_EXPANSIONS = {
|
|
| 212 |
def enhance_query_for_steel_grades(query):
|
| 213 |
"""Expand query with steel grade specific context"""
|
| 214 |
import re
|
| 215 |
-
|
| 216 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
matches = re.findall(steel_pattern, query, re.IGNORECASE)
|
|
|
|
|
|
|
|
|
|
| 218 |
|
| 219 |
-
if not
|
| 220 |
return query
|
| 221 |
|
| 222 |
# Collect context expansions
|
| 223 |
added_context = []
|
| 224 |
grades_found = []
|
| 225 |
|
| 226 |
-
for match in
|
| 227 |
match_upper = match.upper()
|
| 228 |
grades_found.append(match_upper)
|
| 229 |
|
| 230 |
# Check if we have specific context for this grade
|
| 231 |
if match_upper in STEEL_PRODUCT_EXPANSIONS:
|
| 232 |
-
context = STEEL_PRODUCT_EXPANSIONS[match_upper]
|
| 233 |
added_context.append(context)
|
| 234 |
-
log_message(f" Found specific context for {match_upper}")
|
| 235 |
else:
|
| 236 |
# Use generic context for unknown grades
|
| 237 |
added_context.append(GENERIC_STEEL_CONTEXT)
|
|
|
|
| 212 |
def enhance_query_for_steel_grades(query):
|
| 213 |
"""Expand query with steel grade specific context"""
|
| 214 |
import re
|
| 215 |
+
|
| 216 |
+
# FIX: Use the same pattern as normalize_steel_designations
|
| 217 |
+
# Pattern for regular steel grades: 08X18H10T, 12X18H10T, etc.
|
| 218 |
+
steel_pattern = r'\b\d{1,3}(?:[A-Z袗-携衼]\d*)+\b'
|
| 219 |
+
# Pattern for welding wires: 小袙-08X19H10, CB-08X19H10
|
| 220 |
+
wire_pattern = r'\b[小C][袙B]-\d{1,3}(?:[A-Z袗-携衼]\d*)+\b'
|
| 221 |
+
|
| 222 |
matches = re.findall(steel_pattern, query, re.IGNORECASE)
|
| 223 |
+
wire_matches = re.findall(wire_pattern, query, re.IGNORECASE)
|
| 224 |
+
|
| 225 |
+
all_matches = matches + wire_matches
|
| 226 |
|
| 227 |
+
if not all_matches:
|
| 228 |
return query
|
| 229 |
|
| 230 |
# Collect context expansions
|
| 231 |
added_context = []
|
| 232 |
grades_found = []
|
| 233 |
|
| 234 |
+
for match in all_matches:
|
| 235 |
match_upper = match.upper()
|
| 236 |
grades_found.append(match_upper)
|
| 237 |
|
| 238 |
# Check if we have specific context for this grade
|
| 239 |
if match_upper in STEEL_PRODUCT_EXPANSIONS:
|
| 240 |
+
context = ' '.join(STEEL_PRODUCT_EXPANSIONS[match_upper])
|
| 241 |
added_context.append(context)
|
| 242 |
+
log_message(f" Found specific context for {match_upper}: {context}")
|
| 243 |
else:
|
| 244 |
# Use generic context for unknown grades
|
| 245 |
added_context.append(GENERIC_STEEL_CONTEXT)
|