Update scripts to use data.zip instead of local data.
Browse files- DEFT2020.py +24 -21
- data.zip +2 -2
- test_dataset.py +0 -9
DEFT2020.py
CHANGED
|
@@ -62,9 +62,14 @@ _CITATION = """\
|
|
| 62 |
}
|
| 63 |
"""
|
| 64 |
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
| 66 |
"""DEFT 2020 - DEFT (DÉfi Fouille de Textes)"""
|
| 67 |
|
|
|
|
|
|
|
| 68 |
VERSION = datasets.Version("1.0.0")
|
| 69 |
|
| 70 |
BUILDER_CONFIGS = [
|
|
@@ -72,15 +77,13 @@ class FrenchMedMCQA(datasets.GeneratorBasedBuilder):
|
|
| 72 |
datasets.BuilderConfig(name="task_2", version=VERSION, description="Tâche 2 : identifier les phrases parallèles possible pour une phrase source"),
|
| 73 |
]
|
| 74 |
|
| 75 |
-
DEFAULT_CONFIG_NAME = "task_1"
|
| 76 |
-
|
| 77 |
def _info(self):
|
| 78 |
|
| 79 |
if self.config.name == "default":
|
| 80 |
self.config.name = self.DEFAULT_CONFIG_NAME
|
| 81 |
|
| 82 |
if self.config.name == "task_1":
|
| 83 |
-
|
| 84 |
return datasets.DatasetInfo(
|
| 85 |
description=_DESCRIPTION,
|
| 86 |
features=datasets.Features(
|
|
@@ -98,16 +101,16 @@ class FrenchMedMCQA(datasets.GeneratorBasedBuilder):
|
|
| 98 |
citation=_CITATION,
|
| 99 |
license=_LICENSE,
|
| 100 |
)
|
| 101 |
-
|
| 102 |
elif self.config.name == "task_2":
|
| 103 |
-
|
| 104 |
return datasets.DatasetInfo(
|
| 105 |
description=_DESCRIPTION,
|
| 106 |
features=datasets.Features(
|
| 107 |
{
|
| 108 |
"id": datasets.Value("string"),
|
| 109 |
"correct_cible": datasets.features.ClassLabel(
|
| 110 |
-
names
|
| 111 |
),
|
| 112 |
"source": datasets.Value("string"),
|
| 113 |
"cible_1": datasets.Value("string"),
|
|
@@ -124,7 +127,7 @@ class FrenchMedMCQA(datasets.GeneratorBasedBuilder):
|
|
| 124 |
def _split_generators(self, dl_manager):
|
| 125 |
"""Returns SplitGenerators."""
|
| 126 |
|
| 127 |
-
data_dir =
|
| 128 |
|
| 129 |
if self.config.name == "task_1":
|
| 130 |
|
|
@@ -183,16 +186,16 @@ class FrenchMedMCQA(datasets.GeneratorBasedBuilder):
|
|
| 183 |
all_res = []
|
| 184 |
|
| 185 |
if self.config.name == "task_1":
|
| 186 |
-
|
| 187 |
ratio = 0.8316
|
| 188 |
-
|
| 189 |
with open(filepath) as fd:
|
| 190 |
doc = xmltodict.parse(fd.read())
|
| 191 |
|
| 192 |
for d in doc["doc"]["paire"]:
|
| 193 |
|
| 194 |
if int(d["@id"]) > -1:
|
| 195 |
-
|
| 196 |
all_res.append({
|
| 197 |
"id": d["@id"],
|
| 198 |
"vote": d["@vote"],
|
|
@@ -203,9 +206,9 @@ class FrenchMedMCQA(datasets.GeneratorBasedBuilder):
|
|
| 203 |
})
|
| 204 |
|
| 205 |
elif self.config.name == "task_2":
|
| 206 |
-
|
| 207 |
ratio = 0.8059
|
| 208 |
-
|
| 209 |
with open(filepath) as fd:
|
| 210 |
doc = xmltodict.parse(fd.read())
|
| 211 |
|
|
@@ -222,29 +225,29 @@ class FrenchMedMCQA(datasets.GeneratorBasedBuilder):
|
|
| 222 |
|
| 223 |
for t in d["cible"]:
|
| 224 |
obj[f"cible_{t['@num']}"] = t["#text"]
|
| 225 |
-
|
| 226 |
all_res.append(obj)
|
| 227 |
|
| 228 |
if split != "test":
|
| 229 |
-
|
| 230 |
ids = [r["id"] for r in all_res]
|
| 231 |
-
|
| 232 |
random.seed(4)
|
| 233 |
random.shuffle(ids)
|
| 234 |
random.shuffle(ids)
|
| 235 |
random.shuffle(ids)
|
| 236 |
-
|
| 237 |
-
train, validation = np.split(ids, [int(len(ids)*ratio)])
|
| 238 |
-
|
| 239 |
if split == "train":
|
| 240 |
allowed_ids = list(train)
|
| 241 |
elif split == "validation":
|
| 242 |
allowed_ids = list(validation)
|
| 243 |
-
|
| 244 |
for r in all_res:
|
| 245 |
if r["id"] in allowed_ids:
|
| 246 |
yield r["id"], r
|
| 247 |
else:
|
| 248 |
-
|
| 249 |
for r in all_res:
|
| 250 |
yield r["id"], r
|
|
|
|
| 62 |
}
|
| 63 |
"""
|
| 64 |
|
| 65 |
+
_URL = "data.zip"
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
class DEFT2020(datasets.GeneratorBasedBuilder):
|
| 69 |
"""DEFT 2020 - DEFT (DÉfi Fouille de Textes)"""
|
| 70 |
|
| 71 |
+
DEFAULT_CONFIG_NAME = "task_1"
|
| 72 |
+
|
| 73 |
VERSION = datasets.Version("1.0.0")
|
| 74 |
|
| 75 |
BUILDER_CONFIGS = [
|
|
|
|
| 77 |
datasets.BuilderConfig(name="task_2", version=VERSION, description="Tâche 2 : identifier les phrases parallèles possible pour une phrase source"),
|
| 78 |
]
|
| 79 |
|
|
|
|
|
|
|
| 80 |
def _info(self):
|
| 81 |
|
| 82 |
if self.config.name == "default":
|
| 83 |
self.config.name = self.DEFAULT_CONFIG_NAME
|
| 84 |
|
| 85 |
if self.config.name == "task_1":
|
| 86 |
+
|
| 87 |
return datasets.DatasetInfo(
|
| 88 |
description=_DESCRIPTION,
|
| 89 |
features=datasets.Features(
|
|
|
|
| 101 |
citation=_CITATION,
|
| 102 |
license=_LICENSE,
|
| 103 |
)
|
| 104 |
+
|
| 105 |
elif self.config.name == "task_2":
|
| 106 |
+
|
| 107 |
return datasets.DatasetInfo(
|
| 108 |
description=_DESCRIPTION,
|
| 109 |
features=datasets.Features(
|
| 110 |
{
|
| 111 |
"id": datasets.Value("string"),
|
| 112 |
"correct_cible": datasets.features.ClassLabel(
|
| 113 |
+
names=['1', '2', '3'],
|
| 114 |
),
|
| 115 |
"source": datasets.Value("string"),
|
| 116 |
"cible_1": datasets.Value("string"),
|
|
|
|
| 127 |
def _split_generators(self, dl_manager):
|
| 128 |
"""Returns SplitGenerators."""
|
| 129 |
|
| 130 |
+
data_dir = dl_manager.download_and_extract(_URL).rstrip("/")
|
| 131 |
|
| 132 |
if self.config.name == "task_1":
|
| 133 |
|
|
|
|
| 186 |
all_res = []
|
| 187 |
|
| 188 |
if self.config.name == "task_1":
|
| 189 |
+
|
| 190 |
ratio = 0.8316
|
| 191 |
+
|
| 192 |
with open(filepath) as fd:
|
| 193 |
doc = xmltodict.parse(fd.read())
|
| 194 |
|
| 195 |
for d in doc["doc"]["paire"]:
|
| 196 |
|
| 197 |
if int(d["@id"]) > -1:
|
| 198 |
+
|
| 199 |
all_res.append({
|
| 200 |
"id": d["@id"],
|
| 201 |
"vote": d["@vote"],
|
|
|
|
| 206 |
})
|
| 207 |
|
| 208 |
elif self.config.name == "task_2":
|
| 209 |
+
|
| 210 |
ratio = 0.8059
|
| 211 |
+
|
| 212 |
with open(filepath) as fd:
|
| 213 |
doc = xmltodict.parse(fd.read())
|
| 214 |
|
|
|
|
| 225 |
|
| 226 |
for t in d["cible"]:
|
| 227 |
obj[f"cible_{t['@num']}"] = t["#text"]
|
| 228 |
+
|
| 229 |
all_res.append(obj)
|
| 230 |
|
| 231 |
if split != "test":
|
| 232 |
+
|
| 233 |
ids = [r["id"] for r in all_res]
|
| 234 |
+
|
| 235 |
random.seed(4)
|
| 236 |
random.shuffle(ids)
|
| 237 |
random.shuffle(ids)
|
| 238 |
random.shuffle(ids)
|
| 239 |
+
|
| 240 |
+
train, validation = np.split(ids, [int(len(ids) * ratio)])
|
| 241 |
+
|
| 242 |
if split == "train":
|
| 243 |
allowed_ids = list(train)
|
| 244 |
elif split == "validation":
|
| 245 |
allowed_ids = list(validation)
|
| 246 |
+
|
| 247 |
for r in all_res:
|
| 248 |
if r["id"] in allowed_ids:
|
| 249 |
yield r["id"], r
|
| 250 |
else:
|
| 251 |
+
|
| 252 |
for r in all_res:
|
| 253 |
yield r["id"], r
|
data.zip
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d4d69417b3e74595ae78ade05a772f338840af016e073a5d75e1042e2b77cb3a
|
| 3 |
+
size 300044
|
test_dataset.py
DELETED
|
@@ -1,9 +0,0 @@
|
|
| 1 |
-
from datasets import load_dataset
|
| 2 |
-
|
| 3 |
-
dataset = load_dataset("./DEFT2020.py", data_dir="./DEFT2020_T1-T2/", name="task_1")
|
| 4 |
-
print(dataset)
|
| 5 |
-
print(dataset["test"][0])
|
| 6 |
-
|
| 7 |
-
dataset = load_dataset("./DEFT2020.py", data_dir="./DEFT2020_T1-T2/", name="task_2")
|
| 8 |
-
print(dataset)
|
| 9 |
-
print(dataset["test"][0])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|