Download stance_climate/prepare_data.py from SetFit/tweet_eval_stance: direct link, hf CLI and curl.
- Browser
- Download file 523 Bytes
-
https://huggingface.co/datasets/SetFit/tweet_eval_stance/resolve/main/stance_climate/prepare_data.py
- Command line
-
hf download hf://datasets/SetFit/tweet_eval_stance/stance_climate/prepare_data.py
-
curl -L -o prepare_data.py https://huggingface.co/datasets/SetFit/tweet_eval_stance/resolve/main/stance_climate/prepare_data.py
523 Bytes
| from datasets import load_dataset | |
| import json | |
| dataset = load_dataset("tweet_eval", "stance_climate") | |
| id2label = dataset['train'].features['label'].names | |
| for split in ['train', 'test']: | |
| with open(f'{split}.jsonl', 'w') as fOut: | |
| rows = list(dataset[split]) | |
| if split == 'test': | |
| rows += list(dataset['validation']) | |
| for row in rows: | |
| fOut.write(json.dumps({'text': row['text'], 'label': row['label'], 'label_text': id2label[row['label']]})+"\n") | |