Download src/preprocess/Banking77.py from OpenDFM/DialogZoo: direct link, hf CLI and curl.
- Browser
- Download file 759 Bytes
-
https://huggingface.co/datasets/OpenDFM/DialogZoo/resolve/main/src/preprocess/Banking77.py
- Command line
-
hf download hf://datasets/OpenDFM/DialogZoo/src/preprocess/Banking77.py
-
curl -L -o Banking77.py https://huggingface.co/datasets/OpenDFM/DialogZoo/resolve/main/src/preprocess/Banking77.py
759 Bytes
| from utils import write_jsonl_file, read_csv_file, parse | |
| def reformat(args, file): | |
| path = args.input_dir + "/" + file + ".csv" | |
| data = read_csv_file(path) | |
| turns = [] | |
| for i in range(len(data)): | |
| t = { | |
| "turn": "single", | |
| "locale": "en", | |
| "dialog": [ | |
| { | |
| "roles": ["USER"], | |
| "utterance": data["text"][i], | |
| "active_intents": [data["category"][i]], | |
| } | |
| ], | |
| } | |
| turns.append(t) | |
| write_jsonl_file(turns, args.output_dir + "/" + file + ".jsonl") | |
| def preprocess(args): | |
| reformat(args, "train") | |
| reformat(args, "test") | |
| if __name__ == "__main__": | |
| args = parse() | |
| preprocess(args) | |