# -*- 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': '안텔민', 'code': 'S0000001', 'apc': None}, {'name': '안텔민킹(5kg이상)', 'code': 'LB000003157', 'apc': '0230237810109'}, {'name': '안텔민뽀삐(5kg이하)', 'code': 'LB000003158', 'apc': '0230237010107'}, ] print('=== 매칭 테스트 ===\n') print(f'AI 응답:\n{ai_response}\n') print('=' * 50) ai_response_lower = ai_response.lower() ai_response_nospace = ai_response_lower.replace(' ', '') for drug in animal_drugs: drug_name = drug['name'] base_name = drug_name.split('(')[0].split('/')[0].strip() 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() base_lower = base_name.lower() base_nospace = base_lower.replace(' ', '') in_normal = base_lower in ai_response_lower in_nospace = base_nospace in ai_response_nospace matched = len(base_name) >= 2 and (in_normal or in_nospace) print(f'\n제품: {drug_name}') print(f' base_name: "{base_name}"') print(f' base_nospace: "{base_nospace}"') print(f' 일반매칭: {in_normal}') print(f' 공백제거매칭: {in_nospace}') print(f' 최종: {"✅" if matched else "❌"}')