# run_auto_mode_test.sh で実行した6クエリ
# 期待値は test_queries_auto_mode.yaml の各クエリ定義と対応
test_cases = [
    # RAG適合クエリ（spec）: 仕様・スペック情報 → 閾値0.85
    ("Raspberry Pi 5のCPU仕様は？",    "rag",      "spec",  0.85),
    ("Raspberry Pi 5のGPU性能は？",    "rag",      "spec",  0.85),
    ("Raspberry Pi 5のメモリ仕様は？", "rag",      "spec",  0.85),
    # Web適合クエリ（news）: 時間依存の情報 → 閾値0.95
    ("Raspberry Pi 5の最新ニュースは？", "web",    "news",  0.95),
    # Fallback適合クエリ（howto）: 使い方・構築方法 → 閾値0.90
    ("Raspberry Pi 5でDockerを使用するには？",      "fallback", "howto", 0.90),
    ("Raspberry Pi 5でKubernetesを動かすには？",    "fallback", "howto", 0.90),
]

# 分類精度の測定
# 実際の実装は analyze_optimization_results.py の
# analyze_classification_accuracy() 関数を参照
# ここでは理解しやすさのため簡略化したコードを示します
correct = 0
for query, expected_mode, expected_type, expected_threshold in test_cases:
    result = QueryClassifier.classify(query)
    mode = result["mode"]
    query_type = result["query_type"]
    threshold = result["threshold"]
    
    if mode == expected_mode and query_type == expected_type and threshold == expected_threshold:
        correct += 1
        print(f"[OK] {query}")
        print(f"   モード: {mode}, タイプ: {query_type}, 閾値: {threshold}")
    else:
        print(f"[NG] {query}")
        print(f"   実際: {mode}/{query_type}/{threshold}")
        print(f"   期待: {expected_mode}/{expected_type}/{expected_threshold}")

accuracy = correct / len(test_cases) * 100
print(f"\n分類精度: {accuracy:.1f}% ({correct}/{len(test_cases)})")
