File size: 1,483 Bytes
0c3e6f7 f162753 0c3e6f7 75fb74b b84fef5 75fb74b 0c3e6f7 91c9b64 0c3e6f7 a5798a2 0c3e6f7 9f76892 0c3e6f7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
import datasets
import csv
citation='''
@article{white2020frequency,
title={Frequency, acceptability, and selection: A case study of clause-embedding},
author={White, Aaron Steven and Rawlins, Kyle},
journal={arXiv preprint arXiv:2004.04106},
year={2020}
}
'''
class MegaConfig(datasets.BuilderConfig):
citation=citation
files = ['mega-acceptability-v2.tsv', 'mega-intensionality-v1-normalized.tsv', 'mega-negraising-v1-normalized.tsv',
'mega-orientation-v1.1.tsv', 'mega-veridicality-v2.csv']
_URLs = {f:f"https://huggingface.co/datasets/metaeval/mega/resolve/main/{f}" for f in files}
class Mega(datasets.GeneratorBasedBuilder):
BUILDER_CONFIGS = [
MegaConfig(
name='.'.join(n.split('.')[:-1]),
data_dir=n
) for n in files
]
def _split_generators(self, dl_manager: datasets.DownloadManager):
data_file = dl_manager.download(_URLs)
return [
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": data_file[self.config.data_dir]}),
]
def _info(self):
return datasets.DatasetInfo()
def _generate_examples(self, filepath):
with open(filepath, encoding="utf-8") as f:
reader = csv.DictReader(f,delimiter='\t' if '.tsv' in self.config.data_dir else ',')
for id_, row in enumerate(reader):
if id_ == 0:
continue
yield id_, row |