ivykopal commited on
Commit
2103d8d
1 Parent(s): 8b393c0

Delete tasktemplates.py

Browse files
Files changed (1) hide show
  1. tasktemplates.py +0 -120
tasktemplates.py DELETED
@@ -1,120 +0,0 @@
1
- # download templates from the github repository
2
- import yaml
3
- import datasets
4
-
5
-
6
- _PREFIX = 'https://raw.githubusercontent.com/ivanvykopal/tasktemplates/master/src/templates/'
7
-
8
- _DATASETS = [
9
- 'aeslc',
10
- 'anli',
11
- 'billsum',
12
- 'boolq',
13
- 'c4',
14
- 'cb',
15
- 'cnn_dailymail',
16
- 'cola',
17
- 'common_gen',
18
- 'copa',
19
- 'cosmos_qa',
20
- 'cxc',
21
- 'doc_nli',
22
- 'drop',
23
- 'gigaword',
24
- 'hellaswag',
25
- 'hotpot_qa',
26
- 'mnli',
27
- 'mrpc',
28
- 'mrqa',
29
- 'multirc',
30
- 'multi_news',
31
- 'multi_nli',
32
- 'newsqa',
33
- 'newsroom',
34
- 'nq_open',
35
- 'piqa',
36
- 'qnli',
37
- 'qqp',
38
- 'race',
39
- 'record',
40
- 'rte',
41
- 'samsum',
42
- 'search_qa',
43
- 'snli',
44
- 'social_i_qa',
45
- 'squad',
46
- 'sst2',
47
- 'stsb',
48
- 'wic',
49
- 'wiki_auto',
50
- 'wiki_lingua',
51
- 'winogrande',
52
- 'wnli',
53
- 'wsc',
54
- 'xsum'
55
- ]
56
-
57
-
58
- class TaskTemplatesConfig(datasets.BuilderConfig):
59
- def __init__(self, data_url, **kwargs):
60
- super(TaskTemplatesConfig, self).__init__(**kwargs)
61
-
62
- self.data_url = data_url
63
-
64
-
65
- class TaskTemplates(datasets.GeneratorBasedBuilder):
66
- VERSION = datasets.Version("1.0.0")
67
- BUILDER_CONFIGS = [
68
- TaskTemplatesConfig(
69
- name=dataset,
70
- version=datasets.Version("1.0.0"),
71
- data_url=f"{_PREFIX}{dataset}/templates.yaml"
72
- ) for dataset in _DATASETS
73
- ]
74
- BUILDER_CONFIG_CLASS = TaskTemplatesConfig
75
-
76
- def _info(self):
77
- return datasets.DatasetInfo(
78
- description="Task templates for various NLP tasks",
79
- features=datasets.Features(
80
- {
81
- "task": datasets.Value("string"),
82
- "templates": datasets.Sequence(datasets.Value("string"))
83
- }
84
- ),
85
- )
86
-
87
- def _split_generators(self, dl_manager):
88
- urls_to_download = {
89
- 'train': []
90
- }
91
- for dataset in _DATASETS:
92
- urls_to_download['train'].append(
93
- f"{_PREFIX}{dataset}/templates.yaml")
94
-
95
- downloaded_files = dl_manager.download_and_extract(urls_to_download)
96
- splits = []
97
-
98
- if "train" in downloaded_files:
99
- splits.append(
100
- datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={
101
- 'filepath': downloaded_files["train"]})
102
- )
103
-
104
- return splits
105
-
106
- def _generate_examples(self, filepath):
107
- id = 0
108
- for path in filepath:
109
- with open(path, 'r') as file:
110
- template = yaml.load(file, Loader=yaml.FullLoader)
111
- for _, task_templates in template['templates'].items():
112
- for task_template in task_templates:
113
- yield id, {
114
- "name": task_template['name'],
115
- "input": task_template['input'],
116
- "target": task_template['target'],
117
- "languages": task_template['metadata']['languages'],
118
- "metrics": task_template['metadata']['metrics']
119
- }
120
- id += 1