Update DEFT2020.py
Browse files- DEFT2020.py +27 -2
DEFT2020.py
CHANGED
@@ -171,6 +171,8 @@ class FrenchMedMCQA(datasets.GeneratorBasedBuilder):
|
|
171 |
all_res = []
|
172 |
|
173 |
if self.config.name == "task_1":
|
|
|
|
|
174 |
|
175 |
with open(filepath) as fd:
|
176 |
doc = xmltodict.parse(fd.read())
|
@@ -189,6 +191,8 @@ class FrenchMedMCQA(datasets.GeneratorBasedBuilder):
|
|
189 |
})
|
190 |
|
191 |
elif self.config.name == "task_2":
|
|
|
|
|
192 |
|
193 |
with open(filepath) as fd:
|
194 |
doc = xmltodict.parse(fd.read())
|
@@ -209,5 +213,26 @@ class FrenchMedMCQA(datasets.GeneratorBasedBuilder):
|
|
209 |
|
210 |
all_res.append(obj)
|
211 |
|
212 |
-
|
213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
all_res = []
|
172 |
|
173 |
if self.config.name == "task_1":
|
174 |
+
|
175 |
+
ratio = 0.8316
|
176 |
|
177 |
with open(filepath) as fd:
|
178 |
doc = xmltodict.parse(fd.read())
|
|
|
191 |
})
|
192 |
|
193 |
elif self.config.name == "task_2":
|
194 |
+
|
195 |
+
ratio = 0.8059
|
196 |
|
197 |
with open(filepath) as fd:
|
198 |
doc = xmltodict.parse(fd.read())
|
|
|
213 |
|
214 |
all_res.append(obj)
|
215 |
|
216 |
+
if split != "test":
|
217 |
+
|
218 |
+
ids = [r["id"] for r in all_res]
|
219 |
+
|
220 |
+
random.seed(4)
|
221 |
+
random.shuffle(ids)
|
222 |
+
random.shuffle(ids)
|
223 |
+
random.shuffle(ids)
|
224 |
+
|
225 |
+
train, validation = np.split(ids, [int(len(ids)*ratio)])
|
226 |
+
|
227 |
+
if split == "train":
|
228 |
+
allowed_ids = list(train)
|
229 |
+
elif split == "validation":
|
230 |
+
allowed_ids = list(validation)
|
231 |
+
|
232 |
+
for r in all_res:
|
233 |
+
if r["id"] in allowed_ids:
|
234 |
+
yield r["id"], r
|
235 |
+
else:
|
236 |
+
|
237 |
+
for r in all_res:
|
238 |
+
yield r["id"], r
|