File size: 579 Bytes
a1681d2
82b8459
a1681d2
 
 
 
e1c267b
 
 
 
 
82b8459
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import os
from glob import glob
from datasets import load_dataset

os.makedirs('./reference_files', exist_ok=True)


for split in ['validation', 'test']:
    dataset = load_dataset('asahi417/qg_jaquad', split=split)
    for data in ['question', 'answer', 'sentence', 'paragraph']:
        with open('./reference_files/{}-{}.txt'.format(data, split), 'w') as f:
            f.write('\n'.join([i.replace('\n', '') for i in dataset[data]]))
    length = [len(open(i).read().split('\n')) for i in glob(f'reference_files/*{split}.txt')]
    assert len(list(set(length))) == 1, length