Download src/utils.py from abhshkp/structured-data-position-bias: direct link, hf CLI and curl.
- Browser
- Download file 406 Bytes
-
https://huggingface.co/abhshkp/structured-data-position-bias/resolve/main/src/utils.py
- Command line
-
hf download hf://abhshkp/structured-data-position-bias/src/utils.py
-
curl -L -o utils.py https://huggingface.co/abhshkp/structured-data-position-bias/resolve/main/src/utils.py
406 Bytes
| """Utilities.""" | |
| import json | |
| import os | |
| from typing import List, Dict, Any | |
| def ensure_dir(path: str): | |
| os.makedirs(path, exist_ok=True) | |
| def save_jsonl(path: str, records: List[Dict[str, Any]]): | |
| with open(path, "w") as f: | |
| for r in records: | |
| f.write(json.dumps(r) + "\n") | |
| def save_json(path: str, data: Any): | |
| with open(path, "w") as f: | |
| json.dump(data, f, indent=2) | |