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/blob/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.name]}), ] def _info(self): return datasets.DatasetInfo() def _generate_examples(self): with open(self.config.data_dir, 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