#!/usr/bin/env python3
"""
Анализатор шахматных тактик.

Просто запустите: python analyze.py
"""

from chess_detect import ChessDetector

# ===== НАСТРОЙКИ =====
INPUT_FILE = "lichess_Vasil_Bazilio-2016_2026-02-06.pgn"
OUTPUT_FILE = "lichess_Vasil_Bazilio-2016_2026-02-06_analyzed.pgn"
LANG = "ru"  # "ru" или "en"
# =====================


def main():
    print(f"Читаю: {INPUT_FILE}")

    with open(INPUT_FILE, "r", encoding="utf-8") as f:
        pgn = f.read()

    # Считаем количество партий
    game_count = pgn.count("[Event ")
    print(f"Найдено партий: {game_count}")

    print(f"Анализирую...")
    detector = ChessDetector(lang=LANG)
    result = detector.analyze(pgn)

    with open(OUTPUT_FILE, "w", encoding="utf-8") as f:
        f.write(result)

    print(f"Готово! Сохранено: {OUTPUT_FILE}")


if __name__ == "__main__":
    main()
