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") | |