feat: 자재 분류 시스템 대폭 개선
🔧 주요 개선사항: - EXCLUDE 분류기 추가 (WELD GAP 등 제외 대상 처리) - FITTING 분류기 키워드 확장 (ELL, RED 추가) - PIPE 재질 중복 문제 해결 (material_grade 파싱 개선) - NIPPLE 특별 처리 추가 (스케줄 + 길이 정보 포함) - OLET 타입 중복 표시 제거 📊 분류 정확도: - UNKNOWN: 0개 (100% 분류 성공) - EXCLUDE: 1,014개 (제외 대상) - 실제 자재: 1,823개 정확 분류 🎯 해결된 문제: - PIPE 재질 'ASTM A106 ASTM A106' → 'ASTM A106 GR B' - WELD GAP 오분류 → EXCLUDE 카테고리 - FITTING 키워드 인식 실패 → ELL, RED 키워드 추가 - 프론트엔드 중복 표시 제거
This commit is contained in:
85
backend/app/services/exclude_classifier.py
Normal file
85
backend/app/services/exclude_classifier.py
Normal file
@@ -0,0 +1,85 @@
|
||||
"""
|
||||
EXCLUDE 분류 시스템
|
||||
실제 자재가 아닌 계산용/제외 항목들 분류
|
||||
"""
|
||||
|
||||
import re
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
# ========== 제외 대상 타입 ==========
|
||||
EXCLUDE_TYPES = {
|
||||
"WELD_GAP": {
|
||||
"description_keywords": ["WELD GAP", "WELDING GAP", "GAP", "용접갭", "웰드갭"],
|
||||
"characteristics": "용접 시 수축 고려용 계산 항목",
|
||||
"reason": "실제 자재 아님 - 용접 갭 계산용"
|
||||
},
|
||||
"CUTTING_LOSS": {
|
||||
"description_keywords": ["CUTTING LOSS", "CUT LOSS", "절단로스", "컷팅로스"],
|
||||
"characteristics": "절단 시 손실 고려용 계산 항목",
|
||||
"reason": "실제 자재 아님 - 절단 로스 계산용"
|
||||
},
|
||||
"SPARE_ALLOWANCE": {
|
||||
"description_keywords": ["SPARE", "ALLOWANCE", "여유분", "스페어"],
|
||||
"characteristics": "예비품/여유분 계산 항목",
|
||||
"reason": "실제 자재 아님 - 여유분 계산용"
|
||||
},
|
||||
"THICKNESS_NOTE": {
|
||||
"description_keywords": ["THK", "THICK", "두께", "THICKNESS"],
|
||||
"characteristics": "두께 표기용 항목",
|
||||
"reason": "실제 자재 아님 - 두께 정보"
|
||||
},
|
||||
"CALCULATION_ITEM": {
|
||||
"description_keywords": ["CALC", "CALCULATION", "계산", "산정"],
|
||||
"characteristics": "기타 계산용 항목",
|
||||
"reason": "실제 자재 아님 - 계산 목적"
|
||||
}
|
||||
}
|
||||
|
||||
def classify_exclude(dat_file: str, description: str, main_nom: str = "") -> Dict:
|
||||
"""
|
||||
제외 대상 분류
|
||||
|
||||
Args:
|
||||
dat_file: DAT_FILE 필드
|
||||
description: DESCRIPTION 필드
|
||||
main_nom: MAIN_NOM 필드
|
||||
|
||||
Returns:
|
||||
제외 분류 결과
|
||||
"""
|
||||
|
||||
desc_upper = description.upper()
|
||||
|
||||
# 제외 대상 키워드 확인
|
||||
for exclude_type, type_data in EXCLUDE_TYPES.items():
|
||||
for keyword in type_data["description_keywords"]:
|
||||
if keyword in desc_upper:
|
||||
return {
|
||||
"category": "EXCLUDE",
|
||||
"exclude_type": exclude_type,
|
||||
"characteristics": type_data["characteristics"],
|
||||
"reason": type_data["reason"],
|
||||
"overall_confidence": 0.95,
|
||||
"evidence": [f"EXCLUDE_KEYWORD: {keyword}"],
|
||||
"recommendation": "BOM에서 제외 권장"
|
||||
}
|
||||
|
||||
# 제외 대상 아님
|
||||
return {
|
||||
"category": "UNKNOWN",
|
||||
"overall_confidence": 0.0,
|
||||
"reason": "제외 대상 키워드 없음"
|
||||
}
|
||||
|
||||
def is_exclude_item(description: str) -> bool:
|
||||
"""간단한 제외 대상 체크"""
|
||||
desc_upper = description.upper()
|
||||
|
||||
exclude_keywords = [
|
||||
"WELD GAP", "WELDING GAP", "GAP",
|
||||
"CUTTING LOSS", "CUT LOSS",
|
||||
"SPARE", "ALLOWANCE",
|
||||
"THK", "THICK"
|
||||
]
|
||||
|
||||
return any(keyword in desc_upper for keyword in exclude_keywords)
|
||||
Reference in New Issue
Block a user