import re from typing import Dict def classify_structural(tag: str, description: str, main_nom: str = "") -> Dict: """ 형강(STRUCTURAL) 분류기 규격 예: H-BEAM 100x100x6x8 """ desc_upper = description.upper() # 1. 타입 식별 struct_type = "UNKNOWN" if "H-BEAM" in desc_upper or "H-SECTION" in desc_upper: struct_type = "H-BEAM" elif "ANGLE" in desc_upper or "L-SECTION" in desc_upper: struct_type = "ANGLE" elif "CHANNEL" in desc_upper or "C-SECTION" in desc_upper: struct_type = "CHANNEL" elif "BEAM" in desc_upper: struct_type = "I-BEAM" # 2. 규격 추출 # 패턴: 100x100, 100x100x6x8, 50x50x5T, H-200x200 dimension = "" # 숫자와 x 또는 *로 구성된 패턴, 앞에 H- 등이 붙을 수 있음 dim_match = re.search(r'(?:H-|L-|C-)?(\d+(?:\.\d+)?(?:\s*[X\*]\s*\d+(?:\.\d+)?){1,3})', desc_upper) if dim_match: dimension = dim_match.group(1).replace("*", "x") return { "category": "STRUCTURAL", "overall_confidence": 0.9, "details": { "type": struct_type, "dimension": dimension } }