File size: 523 Bytes
bf976af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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")