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