zqwerty
commited on
Commit
·
62f4783
1
Parent(s):
70baea8
add challenge set CM+T
Browse files- CrossWOZ.py +29 -47
CrossWOZ.py
CHANGED
|
@@ -176,46 +176,38 @@ class CrossWOZ(datasets.GeneratorBasedBuilder):
|
|
| 176 |
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLs
|
| 177 |
# 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.
|
| 178 |
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
| 179 |
-
|
| 180 |
return [
|
| 181 |
-
# datasets.SplitGenerator(
|
| 182 |
-
# name=datasets.Split.TRAIN,
|
| 183 |
-
# # These kwargs will be passed to _generate_examples
|
| 184 |
-
# gen_kwargs={
|
| 185 |
-
# "filepath": os.path.join(data_dir, "train.json"),
|
| 186 |
-
# "split": "train",
|
| 187 |
-
# },
|
| 188 |
-
# ),
|
| 189 |
-
# datasets.SplitGenerator(
|
| 190 |
-
# name=datasets.Split.TEST,
|
| 191 |
-
# # These kwargs will be passed to _generate_examples
|
| 192 |
-
# gen_kwargs={
|
| 193 |
-
# "filepath": os.path.join(data_dir, "test.json"),
|
| 194 |
-
# "split": "test"
|
| 195 |
-
# },
|
| 196 |
-
# ),
|
| 197 |
-
# datasets.SplitGenerator(
|
| 198 |
-
# name=datasets.Split.VALIDATION,
|
| 199 |
-
# # These kwargs will be passed to _generate_examples
|
| 200 |
-
# gen_kwargs={
|
| 201 |
-
# "filepath": os.path.join(data_dir, "val.json"),
|
| 202 |
-
# "split": "dev",
|
| 203 |
-
# },
|
| 204 |
-
# ),
|
| 205 |
-
# datasets.SplitGenerator(
|
| 206 |
-
# name="challenge.CM+T",
|
| 207 |
-
# # These kwargs will be passed to _generate_examples
|
| 208 |
-
# gen_kwargs={
|
| 209 |
-
# "filepath": os.path.join(data_dir, "test.json"),
|
| 210 |
-
# "split": "challenge.CM+T",
|
| 211 |
-
# },
|
| 212 |
-
# ),
|
| 213 |
datasets.SplitGenerator(
|
| 214 |
-
name=
|
| 215 |
# These kwargs will be passed to _generate_examples
|
| 216 |
gen_kwargs={
|
| 217 |
-
"filepath":
|
| 218 |
-
"split": "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
},
|
| 220 |
),
|
| 221 |
]
|
|
@@ -271,21 +263,11 @@ class CrossWOZ(datasets.GeneratorBasedBuilder):
|
|
| 271 |
}
|
| 272 |
}
|
| 273 |
|
| 274 |
-
if split == 'challenge':
|
| 275 |
-
with open(filepath, encoding="utf-8") as f:
|
| 276 |
-
for id_, row in enumerate(f):
|
| 277 |
-
data = json.loads(row)
|
| 278 |
-
yield id_, {
|
| 279 |
-
"sentence": data["sentence"],
|
| 280 |
-
"label": data["label"],
|
| 281 |
-
"gem_id": data["gem_id"]
|
| 282 |
-
}
|
| 283 |
-
|
| 284 |
key = 0
|
| 285 |
with open(filepath, encoding="utf-8") as f:
|
| 286 |
data = json.load(f)
|
| 287 |
for dialog_id, dialog in data.items():
|
| 288 |
-
if split == "
|
| 289 |
continue
|
| 290 |
messages = []
|
| 291 |
for turn in dialog["messages"]:
|
|
|
|
| 176 |
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLs
|
| 177 |
# 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.
|
| 178 |
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
| 179 |
+
data_dir = dl_manager.download_and_extract("data.zip")
|
| 180 |
return [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
datasets.SplitGenerator(
|
| 182 |
+
name=datasets.Split.TRAIN,
|
| 183 |
# These kwargs will be passed to _generate_examples
|
| 184 |
gen_kwargs={
|
| 185 |
+
"filepath": os.path.join(data_dir, "train.json"),
|
| 186 |
+
"split": "train",
|
| 187 |
+
},
|
| 188 |
+
),
|
| 189 |
+
datasets.SplitGenerator(
|
| 190 |
+
name=datasets.Split.TEST,
|
| 191 |
+
# These kwargs will be passed to _generate_examples
|
| 192 |
+
gen_kwargs={
|
| 193 |
+
"filepath": os.path.join(data_dir, "test.json"),
|
| 194 |
+
"split": "test"
|
| 195 |
+
},
|
| 196 |
+
),
|
| 197 |
+
datasets.SplitGenerator(
|
| 198 |
+
name=datasets.Split.VALIDATION,
|
| 199 |
+
# These kwargs will be passed to _generate_examples
|
| 200 |
+
gen_kwargs={
|
| 201 |
+
"filepath": os.path.join(data_dir, "val.json"),
|
| 202 |
+
"split": "dev",
|
| 203 |
+
},
|
| 204 |
+
),
|
| 205 |
+
datasets.SplitGenerator(
|
| 206 |
+
name="challenge_CM+T",
|
| 207 |
+
# These kwargs will be passed to _generate_examples
|
| 208 |
+
gen_kwargs={
|
| 209 |
+
"filepath": os.path.join(data_dir, "test.json"),
|
| 210 |
+
"split": "challenge_CM+T",
|
| 211 |
},
|
| 212 |
),
|
| 213 |
]
|
|
|
|
| 263 |
}
|
| 264 |
}
|
| 265 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 266 |
key = 0
|
| 267 |
with open(filepath, encoding="utf-8") as f:
|
| 268 |
data = json.load(f)
|
| 269 |
for dialog_id, dialog in data.items():
|
| 270 |
+
if split == "challenge_CM+T" and dialog["type"] != "不独立多领域+交通":
|
| 271 |
continue
|
| 272 |
messages = []
|
| 273 |
for turn in dialog["messages"]:
|