| 123456789101112131415161718192021 |
- from __future__ import annotations
- import json
- from pathlib import Path
- def load_id_txt(path: str | Path) -> list[str]:
- path = Path(path)
- return [line.strip() for line in path.read_text(encoding="utf-8", errors="ignore").splitlines() if line.strip()]
- def load_json_split(path: str | Path) -> dict[str, list[str]]:
- path = Path(path)
- obj = json.loads(path.read_text(encoding="utf-8"))
- result: dict[str, list[str]] = {}
- for key, value in obj.items():
- result[key] = [str(item) for item in value]
- return result
- __all__ = ["load_id_txt", "load_json_split"]
|