feat: 동물약 APC 일괄 매핑 (7개 완료)
This commit is contained in:
51
backend/scripts/debug_matching.py
Normal file
51
backend/scripts/debug_matching.py
Normal file
@@ -0,0 +1,51 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
import io
|
||||
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
|
||||
|
||||
# 테스트 AI 응답 (실제 응답 시뮬레이션)
|
||||
ai_response = """
|
||||
네, 안텔민은 개와 고양이 모두 사용 가능합니다!
|
||||
|
||||
**안텔민 킹** - 체중 5kg 이상 반려동물용
|
||||
**안텔민 뽀삐** - 체중 5kg 이하 소형 반려동물용
|
||||
|
||||
두 제품 모두 개와 고양이의 내부 기생충 구제에 효과적입니다.
|
||||
"""
|
||||
|
||||
animal_drugs = [
|
||||
{'name': '안텔민킹(5kg이상)', 'code': 'LB000003157'},
|
||||
{'name': '안텔민뽀삐(5kg이하)', 'code': 'LB000003158'},
|
||||
{'name': '다이로하트정M(12~22kg)', 'code': 'LB000003151'},
|
||||
]
|
||||
|
||||
print('=== 현재 매칭 로직 테스트 ===\n')
|
||||
print(f'AI 응답:\n{ai_response}\n')
|
||||
print('=' * 50)
|
||||
|
||||
ai_response_lower = ai_response.lower()
|
||||
|
||||
for drug in animal_drugs:
|
||||
drug_name = drug['name']
|
||||
base_name = drug_name.split('(')[0].split('/')[0].strip()
|
||||
|
||||
# suffix 제거
|
||||
original_base = base_name
|
||||
for suffix in ['정', '액', 'L', 'M', 'S', 'XL', 'XS', 'SS', 'mini']:
|
||||
if base_name.endswith(suffix):
|
||||
base_name = base_name[:-len(suffix)]
|
||||
base_name = base_name.strip()
|
||||
|
||||
matched = base_name.lower() in ai_response_lower
|
||||
|
||||
print(f'\n제품: {drug_name}')
|
||||
print(f' 괄호 앞: {original_base}')
|
||||
print(f' suffix 제거 후: {base_name}')
|
||||
print(f' 매칭 결과: {"✅ 매칭됨" if matched else "❌ 매칭 안됨"}')
|
||||
|
||||
if not matched:
|
||||
# 왜 안 됐는지 확인
|
||||
print(f' → "{base_name.lower()}" in 응답? {base_name.lower() in ai_response_lower}')
|
||||
# 띄어쓰기 변형 체크
|
||||
spaced = base_name.replace('킹', ' 킹').replace('뽀삐', ' 뽀삐')
|
||||
print(f' → 띄어쓰기 변형 "{spaced.lower()}" in 응답? {spaced.lower() in ai_response_lower}')
|
||||
Reference in New Issue
Block a user