"""Load human-supplied corrections. Missing files are not an error."""
import csv
from pathlib import Path


def load_overrides(dates_path: Path, names_path: Path):
    date_overrides: dict[str, tuple[str, str]] = {}
    name_overrides: dict[str, str] = {}
    if Path(dates_path).exists():
        with open(dates_path, encoding="utf-8", newline="") as f:
            for row in csv.DictReader(f):
                raw = (row.get("raw") or "").strip()
                if raw:
                    date_overrides[raw] = ((row.get("iso") or "").strip(), (row.get("precision") or "UNKNOWN").strip())
    if Path(names_path).exists():
        with open(names_path, encoding="utf-8", newline="") as f:
            for row in csv.DictReader(f):
                raw = (row.get("raw") or "").strip()
                if raw:
                    name_overrides[raw] = (row.get("person_id") or "").strip()
    return date_overrides, name_overrides
