# 用法：
#   本文件是库模块，不直接运行。
#   父进程入口：python "src/main.py"
#
# 说明：
#   - 提供统一的词表读取逻辑，供多个 Stage 复用（DRY）。
#   - 词表格式（已与用户确认）：
#       * 每行一个词
#       * 空行忽略
#       * 允许 # 开头注释行忽略

from __future__ import annotations

from pathlib import Path


def load_word_set(path: Path) -> set[str]:
    words: set[str] = set()
    with path.open("r", encoding="utf-8", errors="replace") as f:
        for raw in f:
            line = raw.strip()
            if not line:
                continue
            if line.startswith("#"):
                continue
            words.add(line.lower())
    return words

