from pathlib import Path
from typing import Dict, List


class CorpusLoader:
    """
    Loads raw corpus text files into memory.
    """

    def __init__(self, corpus_dir: str = "corpus_raw"):
        self.corpus_dir = Path(corpus_dir)

    def load(self) -> Dict[str, List[str]]:
        corpus: Dict[str, List[str]] = {}

        if not self.corpus_dir.exists():
            return corpus

        for file in self.corpus_dir.glob("*.txt"):
            with file.open("r", encoding="utf-8") as f:
                corpus[file.stem] = [line.strip() for line in f if line.strip()]

        return corpus
