lannliat commited on
Commit
6084bd4
·
1 Parent(s): a1a7ba3

Fix no dev set case

Browse files
Files changed (1) hide show
  1. multilexnorm.py +59 -33
multilexnorm.py CHANGED
@@ -133,39 +133,65 @@ class MultiLexNorm(datasets.GeneratorBasedBuilder):
133
  # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
134
  # 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.
135
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
136
- _URLS = {
137
- "train": os.path.join(_DATA_DIR, self.config.name, "train.norm"),
138
- "dev": os.path.join(_DATA_DIR, self.config.name, "dev.norm"),
139
- "test": os.path.join(_DATA_DIR, self.config.name, "test.norm"),
140
- }
141
- downloaded_files = dl_manager.download_and_extract(_URLS)
142
-
143
- return [
144
- datasets.SplitGenerator(
145
- name=datasets.Split.TRAIN,
146
- # These kwargs will be passed to _generate_examples
147
- gen_kwargs={
148
- "filepath": downloaded_files["train"],
149
- "split": "train",
150
- },
151
- ),
152
- datasets.SplitGenerator(
153
- name=datasets.Split.VALIDATION,
154
- # These kwargs will be passed to _generate_examples
155
- gen_kwargs={
156
- "filepath": downloaded_files["dev"],
157
- "split": "dev",
158
- },
159
- ),
160
- datasets.SplitGenerator(
161
- name=datasets.Split.TEST,
162
- # These kwargs will be passed to _generate_examples
163
- gen_kwargs={
164
- "filepath": downloaded_files["test"],
165
- "split": "test",
166
- },
167
- ),
168
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
 
170
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
171
  def _generate_examples(self, filepath, split):
 
133
  # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
134
  # 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.
135
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
136
+ try:
137
+ _URLS = {
138
+ "train": os.path.join(_DATA_DIR, self.config.name, "train.norm"),
139
+ "dev": os.path.join(_DATA_DIR, self.config.name, "dev.norm"),
140
+ "test": os.path.join(_DATA_DIR, self.config.name, "test.norm"),
141
+ }
142
+ downloaded_files = dl_manager.download_and_extract(_URLS)
143
+
144
+ return [
145
+ datasets.SplitGenerator(
146
+ name=datasets.Split.TRAIN,
147
+ # These kwargs will be passed to _generate_examples
148
+ gen_kwargs={
149
+ "filepath": downloaded_files["train"],
150
+ "split": "train",
151
+ },
152
+ ),
153
+ datasets.SplitGenerator(
154
+ name=datasets.Split.VALIDATION,
155
+ # These kwargs will be passed to _generate_examples
156
+ gen_kwargs={
157
+ "filepath": downloaded_files["dev"],
158
+ "split": "dev",
159
+ },
160
+ ),
161
+ datasets.SplitGenerator(
162
+ name=datasets.Split.TEST,
163
+ # These kwargs will be passed to _generate_examples
164
+ gen_kwargs={
165
+ "filepath": downloaded_files["test"],
166
+ "split": "test",
167
+ },
168
+ ),
169
+ ]
170
+ except FileNotFoundError:
171
+ _URLS = {
172
+ "train": os.path.join(_DATA_DIR, self.config.name, "train.norm"),
173
+ "test": os.path.join(_DATA_DIR, self.config.name, "test.norm"),
174
+ }
175
+ downloaded_files = dl_manager.download_and_extract(_URLS)
176
+
177
+ return [
178
+ datasets.SplitGenerator(
179
+ name=datasets.Split.TRAIN,
180
+ # These kwargs will be passed to _generate_examples
181
+ gen_kwargs={
182
+ "filepath": downloaded_files["train"],
183
+ "split": "train",
184
+ },
185
+ ),
186
+ datasets.SplitGenerator(
187
+ name=datasets.Split.TEST,
188
+ # These kwargs will be passed to _generate_examples
189
+ gen_kwargs={
190
+ "filepath": downloaded_files["test"],
191
+ "split": "test",
192
+ },
193
+ ),
194
+ ]
195
 
196
  # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
197
  def _generate_examples(self, filepath, split):