#!/usr/bin/env python3
"""
测试Bogner特定的货号格式
"""

import sys
import os

# 添加项目根目录到路径
sys.path.insert(0, os.path.join(os.path.dirname(__file__)))

from app.utils.text_parser import ProductCodeExtractor

def test_bogner_specific():
    """测试Bogner特定的货号格式"""
    extractor = ProductCodeExtractor()
    
    test_cases = [
        {
            'name': "小王国Bogner博格纳女款橘色排骨夹克RHEA2-O代购8.16",
            'expected': "RHEA2-O",
            'current': "RHEA2",
            'format': "字母数字-字母"
        },
        {
            'name': "小王国Bogner博格纳女款白色滑雪图案短袖T恤DEBRA4 003代购8.16",
            'expected': "DEBRA4 003", 
            'current': "DEBRA4",
            'format': "字母数字+空格+数字"
        },
        {
            'name': "小王国Bogner博格纳女款浅色羽绒夹克KOSY 代购8.16",
            'expected': "KOSY",
            'current': "KOSY", 
            'format': "纯字母"
        },
        {
            'name': "小王国Bogner博格纳 女款短款双面排骨马甲ALIAH代购8.16",
            'expected': "ALIAH",
            'current': "ALIAH",
            'format': "纯字母"
        },
        {
            'name': "小王国Bogner博格纳女款深色条纹拉链夹克AISHA3代购8.16",
            'expected': "AISHA3",
            'current': "AISHA3",
            'format': "字母+数字"
        }
    ]
    
    print("=== Bogner特定货号格式测试 ===")
    
    issues_found = 0
    
    for i, case in enumerate(test_cases, 1):
        product_code = extractor.extract_product_code(case['name'], "Bogner")
        status = "✓" if product_code == case['expected'] else "✗"
        
        if product_code != case['expected']:
            issues_found += 1
        
        print(f"\n测试 {i}: {status} [{case['format']}]")
        print(f"商品名称: {case['name']}")
        print(f"期望货号: {case['expected']}")
        print(f"实际货号: {product_code}")
        print(f"当前结果: {case['current']}")
        
        if product_code == case['expected']:
            print("✅ 匹配成功")
        else:
            print("❌ 需要改进")
    
    print(f"\n=== 问题总结 ===")
    print(f"需要改进的格式: {issues_found}/{len(test_cases)}")
    
    if issues_found > 0:
        print("\n需要添加的模式:")
        print("1. RHEA2-O格式: 字母+数字+-+字母")
        print("2. DEBRA4 003格式: 字母+数字+空格+数字")

if __name__ == "__main__":
    test_bogner_specific()