ncoop57 commited on
Commit
3ee80f9
1 Parent(s): c95cf9a

Add new csvs for training, testing and validation models and python script for working with hf datasets lib

Browse files
completeformer-masked.py ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The HuggingFace Datasets Authors and the Semeru Lab and SEART research group.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ """TODO: Add a description here."""
16
+
17
+
18
+ import csv
19
+ import glob
20
+ import os
21
+
22
+ import datasets
23
+
24
+ import numpy as np
25
+
26
+ # TODO: Add BibTeX citation
27
+ # Find for instance the citation on arxiv or on the dataset repo/website
28
+ _CITATION = """\
29
+ @InProceedings{huggingface:dataset,
30
+ title = {A great new dataset},
31
+ author={huggingface, Inc.
32
+ },
33
+ year={2020}
34
+ }
35
+ """
36
+
37
+ # TODO: Add description of the dataset here
38
+ # You can copy an official description
39
+ _DESCRIPTION = """\
40
+ This new dataset is designed to solve this great NLP task and is crafted with a lot of care.
41
+ """
42
+
43
+ # TODO: Add a link to an official homepage for the dataset here
44
+ _HOMEPAGE = ""
45
+
46
+ # TODO: Add the licence for the dataset here if you can find it
47
+ _LICENSE = ""
48
+
49
+ # TODO: Add link to the official dataset URLs here
50
+ # The HuggingFace dataset library don't host the datasets but only point to the original files
51
+ # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
52
+ _DATA_URLs = {
53
+ "tokenizer": "https://cdn-lfs.huggingface.co/datasets/semeru/completeformer-masked/30668967d62b849f48db64ff26c0d2b92bd08d940471b80b80ce2ff39bd8358e",
54
+ "all": {
55
+ "train": "https://cdn-lfs.huggingface.co/datasets/semeru/completeformer-masked/30668967d62b849f48db64ff26c0d2b92bd08d940471b80b80ce2ff39bd8358e",
56
+ "valid": "https://cdn-lfs.huggingface.co/datasets/semeru/completeformer-masked/30668967d62b849f48db64ff26c0d2b92bd08d940471b80b80ce2ff39bd8358e",
57
+ "test": "https://cdn-lfs.huggingface.co/datasets/semeru/completeformer-masked/30668967d62b849f48db64ff26c0d2b92bd08d940471b80b80ce2ff39bd8358e",
58
+ },
59
+ }
60
+
61
+
62
+ # TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
63
+ class CSNCHumanJudgementDataset(datasets.GeneratorBasedBuilder):
64
+ """TODO: Short description of my dataset."""
65
+
66
+ VERSION = datasets.Version("1.1.0")
67
+
68
+ # This is an example of a dataset with multiple configurations.
69
+ # If you don't want/need to define several sub-sets in your dataset,
70
+ # just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
71
+
72
+ # If you need to make complex sub-parts in the datasets with configurable options
73
+ # You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
74
+ # BUILDER_CONFIG_CLASS = MyBuilderConfig
75
+
76
+ # You will be able to load one or the other configurations in the following list with
77
+ # data = datasets.load_dataset('my_dataset', 'first_domain')
78
+ # data = datasets.load_dataset('my_dataset', 'second_domain')
79
+ BUILDER_CONFIGS = [
80
+ datasets.BuilderConfig(
81
+ name="all",
82
+ version=VERSION,
83
+ description="",
84
+ ),
85
+ datasets.BuilderConfig(
86
+ name="tokenizer",
87
+ version=VERSION,
88
+ description="",
89
+ ),
90
+ ]
91
+
92
+ DEFAULT_CONFIG_NAME = "all"
93
+
94
+ def _info(self):
95
+ if self.config.name == "tokenizer":
96
+ features = datasets.Features(
97
+ {
98
+ "function": datasets.Value("string"),
99
+ }
100
+ )
101
+ else:
102
+ features = datasets.Features(
103
+ {
104
+ "method": datasets.Value("string"),
105
+ "block": datasets.Value("string"),
106
+ "complex_masked_block": datasets.Value("string"),
107
+ "complex_input": datasets.Value("string"),
108
+ "complex_target": datasets.Value("string"),
109
+ "medium_masked_block": datasets.Value("string"),
110
+ "medium_input": datasets.Value("string"),
111
+ "medium_target": datasets.Value("string"),
112
+ "simple_masked_block": datasets.Value("string"),
113
+ "simple_input": datasets.Value("string"),
114
+ "simple_target": datasets.Value("string"),
115
+ }
116
+ )
117
+
118
+ return datasets.DatasetInfo(
119
+ description=_DESCRIPTION,
120
+ features=features,
121
+ supervised_keys=None,
122
+ homepage=_HOMEPAGE,
123
+ license=_LICENSE,
124
+ citation=_CITATION,
125
+ )
126
+
127
+ def _split_generators(self, dl_manager):
128
+ """Returns SplitGenerators."""
129
+ # TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
130
+ # If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
131
+
132
+ # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLs
133
+ # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
134
+ # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
135
+ my_urls = _DATA_URLs[self.config.name]
136
+ if self.config.name == "tokenizer":
137
+ data_dir = dl_manager.download_and_extract(my_urls)
138
+ return [
139
+ datasets.SplitGenerator(
140
+ name=datasets.Split.TRAIN,
141
+ gen_kwargs={"filepath": data_dir},
142
+ ),
143
+ ]
144
+ else:
145
+ data_dirs = {}
146
+ for k, v in my_urls.items():
147
+ data_dirs[k] = dl_manager.download_and_extract(v)
148
+ return [
149
+ datasets.SplitGenerator(
150
+ name=datasets.Split.TRAIN,
151
+ # These kwargs will be passed to _generate_examples
152
+ gen_kwargs={
153
+ "file_path": data_dirs["train"],
154
+ },
155
+ ),
156
+ datasets.SplitGenerator(
157
+ name=datasets.Split.VALIDATION,
158
+ # These kwargs will be passed to _generate_examples
159
+ gen_kwargs={
160
+ "file_path": data_dirs["valid"],
161
+ },
162
+ ),
163
+ datasets.SplitGenerator(
164
+ name=datasets.Split.TEST,
165
+ # These kwargs will be passed to _generate_examples
166
+ gen_kwargs={
167
+ "file_path": data_dirs["test"],
168
+ },
169
+ ),
170
+ ]
171
+
172
+ def _generate_examples(
173
+ self,
174
+ file_path,
175
+ ):
176
+ """Yields examples as (key, example) tuples."""
177
+ # This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
178
+ # The `key` is here for legacy reason (tfds) and is not important in itself.
179
+
180
+ with open(file_path, encoding="utf-8") as f:
181
+ csv_reader = csv.reader(f, quotechar='"', delimiter=",", quoting=csv.QUOTE_ALL, skipinitialspace=True)
182
+ next(csv_reader, None) # skip header
183
+
184
+ for row_id, row in enumerate(csv_reader):
185
+ if self.config.name == "tokenizer":
186
+ yield row_id, {
187
+ "function": row[1],
188
+ }
189
+ else:
190
+ _, method, block, complex_masked_block, complex_input, complex_target, medium_masked_block, medium_input, medium_target, simple_masked_block, simple_input, simple_target = row
191
+ yield row_id, {
192
+ "method": method,
193
+ "block": block,
194
+ "complex_masked_block": complex_masked_block,
195
+ "complex_input": complex_input,
196
+ "complex_target": complex_target,
197
+ "medium_masked_block": medium_masked_block,
198
+ "medium_input": medium_input,
199
+ "medium_target": medium_target,
200
+ "simple_masked_block": simple_masked_block,
201
+ "simple_input": simple_input,
202
+ "simple_target": simple_target,
203
+ }
test_clean.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:861606eea456617389625c6d2b1680875438e623e0582288d9814e8289c060d6
3
+ size 533318567
training_clean.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f39db3b2843aa34c2956fae91a379c30953cd06dde8b783e245f3325cca906ee
3
+ size 4270744191
validation_clean.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7591e528bd8e712d1b7d61ed328f9d371d90f7b70a192b0eb8b00196611f4ecd
3
+ size 535985056