Download annotations/annotation_100/MPSC/src/utils.py from mcy98/RECODE-H: direct link, hf CLI and curl.
- Browser
- Download file 673 Bytes
-
https://huggingface.co/datasets/mcy98/RECODE-H/resolve/main/annotations/annotation_100/MPSC/src/utils.py
- Command line
-
hf download hf://datasets/mcy98/RECODE-H/annotations/annotation_100/MPSC/src/utils.py
-
curl -L -o utils.py https://huggingface.co/datasets/mcy98/RECODE-H/resolve/main/annotations/annotation_100/MPSC/src/utils.py
673 Bytes
| import os | |
| import json | |
| import pickle | |
| global debug | |
| debug = False | |
| def load_jsonl(filename): | |
| with open(filename, "r") as f: | |
| return [json.loads(line) for line in f] | |
| def load_pickle(filename): | |
| with open(filename, "rb") as f: | |
| return pickle.load(f) | |
| def dump_jsonl(data, filename): | |
| if debug: | |
| print("Debug Mode: Skip dumping jsonl") | |
| return | |
| with open(filename, "w") as f: | |
| for line in data: | |
| json.dump(line, f) | |
| f.write("\n") | |
| def dump_pickle(data, filename): | |
| if debug: | |
| print("Debug Mode: Skip dumping pickle") | |
| return | |
| with open(filename, "wb") as f: | |
| pickle.dump(data, f) | |