볼트 분류 개선 및 업로드 성능 최적화
- 볼트 길이 추출 로직 개선: '70.0000 LG' 형태 인식 추가 - 재질 중복 표시 수정: 'ASTM A193 ASTM A193 B7' → 'B7' - A193/A194 등급 추출 로직 개선: 'GR B7/2H' 형태 지원 - bolt_details 테이블에 pressure_rating 컬럼 추가 - 볼트 분류기 오분류 방지: 플랜지/피팅이 볼트로 분류되지 않도록 수정 - 업로드 성능 개선: 키워드 기반 빠른 분류기 선택 로직 추가 - 분류 키워드 대폭 확장: 피팅/파이프/플랜지 키워드 추가
This commit is contained in:
@@ -46,7 +46,7 @@ INSTRUMENT_TYPES = {
|
||||
}
|
||||
}
|
||||
|
||||
def classify_instrument(dat_file: str, description: str, main_nom: str, length: float = None) -> Dict:
|
||||
def classify_instrument(dat_file: str, description: str, main_nom: str, length: Optional[float] = None) -> Dict:
|
||||
"""
|
||||
간단한 INSTRUMENT 분류
|
||||
|
||||
@@ -59,16 +59,62 @@ def classify_instrument(dat_file: str, description: str, main_nom: str, length:
|
||||
간단한 계기 분류 결과
|
||||
"""
|
||||
|
||||
# 1. 재질 분류 (공통 모듈)
|
||||
# 1. 먼저 계기인지 확인 (계기 키워드가 있어야 함)
|
||||
desc_upper = description.upper()
|
||||
dat_upper = dat_file.upper()
|
||||
combined_text = f"{dat_upper} {desc_upper}"
|
||||
|
||||
# 계기 관련 키워드 확인
|
||||
instrument_keywords = [
|
||||
"GAUGE", "METER", "TRANSMITTER", "INDICATOR", "SENSOR",
|
||||
"THERMOMETER", "MANOMETER", "ROTAMETER", "THERMOWELL",
|
||||
"ORIFICE PLATE", "DISPLAY", "4-20MA", "4-20 MA",
|
||||
"압력계", "온도계", "유량계", "액위계", "게이지", "계기",
|
||||
"트랜스미터", "지시계", "센서"
|
||||
]
|
||||
|
||||
# 계기가 아닌 것들의 키워드
|
||||
non_instrument_keywords = [
|
||||
"BOLT", "SCREW", "STUD", "NUT", "WASHER", "볼트", "나사", "너트", "와셔",
|
||||
"PIPE", "TUBE", "파이프", "배관",
|
||||
"ELBOW", "TEE", "REDUCER", "CAP", "엘보", "티", "리듀서",
|
||||
"VALVE", "GATE", "BALL", "GLOBE", "CHECK", "밸브",
|
||||
"FLANGE", "FLG", "플랜지",
|
||||
"GASKET", "GASK", "가스켓"
|
||||
]
|
||||
|
||||
# 계기가 아닌 키워드가 있으면 거부
|
||||
if any(keyword in combined_text for keyword in non_instrument_keywords):
|
||||
return {
|
||||
"category": "UNKNOWN",
|
||||
"overall_confidence": 0.1,
|
||||
"reason": "NON_INSTRUMENT_KEYWORDS_DETECTED"
|
||||
}
|
||||
|
||||
# 계기 키워드가 없으면 거부
|
||||
has_instrument_keyword = any(keyword in combined_text for keyword in instrument_keywords)
|
||||
if not has_instrument_keyword:
|
||||
return {
|
||||
"category": "UNKNOWN",
|
||||
"overall_confidence": 0.1,
|
||||
"reason": "NO_INSTRUMENT_KEYWORDS_FOUND"
|
||||
}
|
||||
|
||||
# 2. 재질 분류 (공통 모듈)
|
||||
material_result = classify_material(description)
|
||||
|
||||
# 2. 계기 타입 분류
|
||||
# 3. 계기 타입 분류
|
||||
instrument_type_result = classify_instrument_type(dat_file, description)
|
||||
|
||||
# 3. 측정 범위 추출 (있다면)
|
||||
# 4. 측정 범위 추출 (있다면)
|
||||
measurement_range = extract_measurement_range(description)
|
||||
|
||||
# 4. 최종 결과
|
||||
# 5. 전체 신뢰도 계산
|
||||
base_confidence = 0.8 if has_instrument_keyword else 0.1
|
||||
instrument_confidence = instrument_type_result.get('confidence', 0.0)
|
||||
overall_confidence = (base_confidence + instrument_confidence) / 2
|
||||
|
||||
# 6. 최종 결과
|
||||
return {
|
||||
"category": "INSTRUMENT",
|
||||
|
||||
@@ -105,11 +151,8 @@ def classify_instrument(dat_file: str, description: str, main_nom: str, length:
|
||||
"note": "사양서 확인 후 주문"
|
||||
},
|
||||
|
||||
# 간단한 신뢰도
|
||||
"overall_confidence": calculate_simple_confidence([
|
||||
material_result.get('confidence', 0),
|
||||
instrument_type_result.get('confidence', 0)
|
||||
])
|
||||
# 전체 신뢰도
|
||||
"overall_confidence": overall_confidence
|
||||
}
|
||||
|
||||
def classify_instrument_type(dat_file: str, description: str) -> Dict:
|
||||
|
||||
Reference in New Issue
Block a user