Files
tk-factory-services/tkeg/api/app/services/test_bolt_classifier.py
2026-03-16 15:41:58 +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()