Download create_dataset.py from SetFit/hate_speech18: direct link, hf CLI and curl.
- Browser
- Download file 353 Bytes
-
https://huggingface.co/datasets/SetFit/hate_speech18/resolve/main/create_dataset.py
- Command line
-
hf download hf://datasets/SetFit/hate_speech18/create_dataset.py
-
curl -L -o create_dataset.py https://huggingface.co/datasets/SetFit/hate_speech18/resolve/main/create_dataset.py
353 Bytes
| from datasets import load_dataset | |
| def main(): | |
| raw_dset = load_dataset("hate_speech18") | |
| labels = raw_dset["train"].features["label"] | |
| for split, dset in raw_dset.items(): | |
| dset = dset.map(lambda x: {"label_text": labels.int2str(x["label"])}, num_proc=4) | |
| dset.to_json(f"{split}.jsonl") | |
| if __name__ == "__main__": | |
| main() | |