Datasets:
lmqg
/

Modalities:
Tabular
Text
Languages:
English
ArXiv:
Libraries:
Datasets
License:
qg_subjqa / generate_reference_files.py
asahi417's picture
update
7626e35
raw
history blame
785 Bytes
import os
from glob import glob
from datasets import load_dataset
os.makedirs('./reference_files', exist_ok=True)
for split in ['validation', 'test']:
for domain in ["default", "books", "electronics", "grocery", "movies", "restaurants", "tripadvisor"]:
dataset = load_dataset('asahi417/qg_subjqa', domain, split=split)
for data in ['question', 'answer', 'sentence', 'paragraph']:
with open('./reference_files/{}-{}.{}txt'.format(data, split, "" if domain == 'default' else f"{domain}."), 'w') as f:
f.write('\n'.join(dataset[data]))
if domain != 'default':
length = [len(open(i).read().split('\n')) for i in glob(f'reference_files/*{split}*{domain}*.txt')]
assert len(list(set(length))) == 1, length