볼트 분류 개선 및 업로드 성능 최적화

- 볼트 길이 추출 로직 개선: '70.0000 LG' 형태 인식 추가
- 재질 중복 표시 수정: 'ASTM A193 ASTM A193 B7' → 'B7'
- A193/A194 등급 추출 로직 개선: 'GR B7/2H' 형태 지원
- bolt_details 테이블에 pressure_rating 컬럼 추가
- 볼트 분류기 오분류 방지: 플랜지/피팅이 볼트로 분류되지 않도록 수정
- 업로드 성능 개선: 키워드 기반 빠른 분류기 선택 로직 추가
- 분류 키워드 대폭 확장: 피팅/파이프/플랜지 키워드 추가
This commit is contained in:
Hyungi Ahn
2025-07-18 12:48:24 +09:00
parent 25ce3590ee
commit 3dd301cb57
13 changed files with 1184 additions and 106 deletions

View File

@@ -225,6 +225,9 @@ def classify_fitting(dat_file: str, description: str, main_nom: str,
# 4. 압력 등급 분류
pressure_result = classify_pressure_rating(dat_file, description)
# 4.5. 스케줄 분류 (니플 등에 중요)
schedule_result = classify_fitting_schedule(description)
# 5. 제작 방법 추정
manufacturing_result = determine_fitting_manufacturing(
material_result, connection_result, pressure_result, main_nom
@@ -279,6 +282,14 @@ def classify_fitting(dat_file: str, description: str, main_nom: str,
"requires_two_sizes": fitting_type_result.get('requires_two_sizes', False)
},
"schedule_info": {
"schedule": schedule_result.get('schedule', 'UNKNOWN'),
"schedule_number": schedule_result.get('schedule_number', ''),
"wall_thickness": schedule_result.get('wall_thickness', ''),
"pressure_class": schedule_result.get('pressure_class', ''),
"confidence": schedule_result.get('confidence', 0.0)
},
# 전체 신뢰도
"overall_confidence": calculate_fitting_confidence({
"material": material_result.get('confidence', 0),
@@ -615,3 +626,51 @@ def get_fitting_purchase_info(fitting_result: Dict) -> Dict:
"purchase_category": f"{fitting_type} {connection} {pressure}",
"manufacturing_note": fitting_result["manufacturing"]["characteristics"]
}
def classify_fitting_schedule(description: str) -> Dict:
"""피팅 스케줄 분류 (특히 니플용)"""
desc_upper = description.upper()
# 스케줄 패턴 매칭
schedule_patterns = [
r'SCH\s*(\d+)',
r'SCHEDULE\s*(\d+)',
r'스케줄\s*(\d+)'
]
for pattern in schedule_patterns:
match = re.search(pattern, desc_upper)
if match:
schedule_number = match.group(1)
schedule = f"SCH {schedule_number}"
# 일반적인 스케줄 정보
common_schedules = {
"10": {"wall": "얇음", "pressure": "저압"},
"20": {"wall": "얇음", "pressure": "저압"},
"40": {"wall": "표준", "pressure": "중압"},
"80": {"wall": "두꺼움", "pressure": "고압"},
"120": {"wall": "매우 두꺼움", "pressure": "고압"},
"160": {"wall": "매우 두꺼움", "pressure": "초고압"}
}
schedule_info = common_schedules.get(schedule_number, {"wall": "비표준", "pressure": "확인 필요"})
return {
"schedule": schedule,
"schedule_number": schedule_number,
"wall_thickness": schedule_info["wall"],
"pressure_class": schedule_info["pressure"],
"confidence": 0.95,
"matched_pattern": pattern
}
return {
"schedule": "UNKNOWN",
"schedule_number": "",
"wall_thickness": "",
"pressure_class": "",
"confidence": 0.0,
"matched_pattern": ""
}