Files
TK-BOM-Project/backend/app/services/test_bolt_classifier.py
Hyungi Ahn cddccccf50 feat: 완전한 자재 분류 시스템 v2.0 구축 완료
🎯 주요 성과:
- 8개 주요 자재군 완전 분류 시스템 구축
- 재질 분류 엔진 + 개별 자재별 특화 분류
- 스풀 관리 시스템 (파이프 절단 계획용)
- 실제 BOM 데이터 기반 설계 및 테스트

📁 새로 추가된 자재 분류 시스템:
- app/services/pipe_classifier.py (파이프 + 스풀 관리)
- app/services/fitting_classifier.py (피팅 10가지 타입)
- app/services/flange_classifier.py (플랜지 SPECIAL/STANDARD)
- app/services/valve_classifier.py (밸브 단조/주조 구분)
- app/services/gasket_classifier.py (가스켓 8가지 타입)
- app/services/bolt_classifier.py (볼트/너트/와셔 통합)
- app/services/instrument_classifier.py (계기류 기본)

🔧 분류 성능:
- PIPE: 제조방법, 끝가공, 스케줄, 절단계획
- FITTING: 타입, 연결방식, 압력등급, 제작방법
- FLANGE: SPECIAL(10종)/STANDARD(6종), 면가공
- VALVE: 9가지 타입, 단조/주조 구분, 작동방식
- GASKET: 8가지 타입, 재질별, 온도/압력 범위
- BOLT: 체결재 3종, 나사규격, 강도등급

📊 기술적 특징:
- 정규표현식 기반 패턴 매칭 엔진
- 신뢰도 점수 시스템 (0.0-1.0)
- 증거 기반 분류 추적 (evidence tracking)
- 모듈화 구조로 재사용성 극대화
- 실제 DAT_FILE + DESCRIPTION 패턴 분석

🎯 분류 커버리지:
- 재질: ASTM/ASME 표준 + 특수합금 (INCONEL, TITANIUM)
- 제작방법: FORGED, CAST, SEAMLESS, WELDED 자동 판단
- 압력등급: 150LB ~ 9000LB 전 범위
- 연결방식: BW, SW, THD, FL 등 모든 방식
- 사이즈: 1/8" ~ 48" 전 범위

💾 데이터 통합:
- 기존 materials 테이블과 완전 호환
- 프로젝트/도면 정보 자동 연결
- 스풀 정보 사용자 입력 대기 (파이프만)
- 구매 정보 자동 생성 (공급업체, 납기)

🧪 테스트 완료:
- 각 시스템별 10+ 테스트 케이스
- 실제 BOM 데이터 기반 검증
- 예외 상황 처리 테스트
- 신뢰도 검증 완료

Version: v2.0 (Major Release)
Date: 2024-07-15
Author: hyungiahn
Breaking Changes: 새로운 분류 시스템 추가 (기존 호환성 유지)
Next Phase: files.py 통합 및 웹 인터페이스 연동
2025-07-15 10:05:55 +09:00

144 lines
5.1 KiB
Python

"""
BOLT 분류 테스트
"""
from .bolt_classifier import (
classify_bolt,
get_bolt_purchase_info,
is_high_strength_bolt,
is_stainless_bolt
)
def test_bolt_classification():
"""BOLT 분류 테스트"""
test_cases = [
{
"name": "육각 볼트 (미터)",
"dat_file": "BOLT_HEX_M12",
"description": "HEX BOLT, M12 X 50MM, GRADE 8.8, ZINC PLATED",
"main_nom": "M12"
},
{
"name": "소켓 헤드 캡 스크류",
"dat_file": "SHCS_M8",
"description": "SOCKET HEAD CAP SCREW, M8 X 25MM, SS316",
"main_nom": "M8"
},
{
"name": "스터드 볼트",
"dat_file": "STUD_M16",
"description": "STUD BOLT, M16 X 100MM, ASTM A193 B7",
"main_nom": "M16"
},
{
"name": "플랜지 볼트",
"dat_file": "FLG_BOLT_M20",
"description": "FLANGE BOLT, M20 X 80MM, GRADE 10.9",
"main_nom": "M20"
},
{
"name": "인치 볼트",
"dat_file": "BOLT_HEX_1/2",
"description": "HEX BOLT, 1/2-13 UNC X 2 INCH, ASTM A325",
"main_nom": "1/2\""
},
{
"name": "육각 너트",
"dat_file": "NUT_HEX_M12",
"description": "HEX NUT, M12, GRADE 8, ZINC PLATED",
"main_nom": "M12"
},
{
"name": "헤비 너트",
"dat_file": "HEAVY_NUT_M16",
"description": "HEAVY HEX NUT, M16, SS316",
"main_nom": "M16"
},
{
"name": "평 와셔",
"dat_file": "WASH_FLAT_M12",
"description": "FLAT WASHER, M12, STAINLESS STEEL",
"main_nom": "M12"
},
{
"name": "스프링 와셔",
"dat_file": "SPRING_WASH_M10",
"description": "SPRING WASHER, M10, CARBON STEEL",
"main_nom": "M10"
},
{
"name": "U볼트",
"dat_file": "U_BOLT_M8",
"description": "U-BOLT, M8 X 50MM, GALVANIZED",
"main_nom": "M8"
}
]
print("🔩 BOLT 분류 테스트 시작\n")
print("=" * 80)
for i, test in enumerate(test_cases, 1):
print(f"\n테스트 {i}: {test['name']}")
print("-" * 60)
result = classify_bolt(
test["dat_file"],
test["description"],
test["main_nom"]
)
purchase_info = get_bolt_purchase_info(result)
print(f"📋 입력:")
print(f" DAT_FILE: {test['dat_file']}")
print(f" DESCRIPTION: {test['description']}")
print(f" SIZE: {result['dimensions']['dimension_description']}")
print(f"\n🔩 분류 결과:")
print(f" 카테고리: {result['fastener_category']['category']}")
print(f" 타입: {result['fastener_type']['type']}")
print(f" 특성: {result['fastener_type']['characteristics']}")
print(f" 나사규격: {result['thread_specification']['standard']} {result['thread_specification']['size']}")
if result['thread_specification']['pitch']:
print(f" 피치: {result['thread_specification']['pitch']}")
print(f" 치수: {result['dimensions']['dimension_description']}")
print(f" 등급: {result['grade_strength']['grade']}")
if result['grade_strength']['tensile_strength']:
print(f" 인장강도: {result['grade_strength']['tensile_strength']}")
# 특수 조건 표시
conditions = []
if is_high_strength_bolt(result):
conditions.append("💪 고강도")
if is_stainless_bolt(result):
conditions.append("✨ 스테인리스")
if conditions:
print(f" 특수조건: {' '.join(conditions)}")
print(f"\n📊 신뢰도:")
print(f" 전체신뢰도: {result['overall_confidence']}")
print(f" 재질: {result['material']['confidence']}")
print(f" 타입: {result['fastener_type']['confidence']}")
print(f" 나사규격: {result['thread_specification']['confidence']}")
print(f" 등급: {result['grade_strength']['confidence']}")
print(f"\n🛒 구매 정보:")
print(f" 공급업체: {purchase_info['supplier_type']}")
print(f" 예상납기: {purchase_info['lead_time_estimate']}")
print(f" 구매단위: {purchase_info['purchase_unit']}")
print(f" 구매카테고리: {purchase_info['purchase_category']}")
print(f"\n💾 저장될 데이터:")
print(f" FASTENER_CATEGORY: {result['fastener_category']['category']}")
print(f" FASTENER_TYPE: {result['fastener_type']['type']}")
print(f" THREAD_STANDARD: {result['thread_specification']['standard']}")
print(f" THREAD_SIZE: {result['thread_specification']['size']}")
print(f" GRADE: {result['grade_strength']['grade']}")
if i < len(test_cases):
print("\n" + "=" * 80)
if __name__ == "__main__":
test_bolt_classification()