zqwerty
commited on
Commit
·
e111ca7
1
Parent(s):
a6a5745
use relative path
Browse files- CrossWOZ.py +7 -17
CrossWOZ.py
CHANGED
|
@@ -42,9 +42,9 @@ _HOMEPAGE = "https://github.com/thu-coai/CrossWOZ"
|
|
| 42 |
_LICENSE = "Apache License, Version 2.0"
|
| 43 |
|
| 44 |
_URLs = {
|
| 45 |
-
"train": "
|
| 46 |
-
"val": "
|
| 47 |
-
"test": "
|
| 48 |
}
|
| 49 |
|
| 50 |
|
|
@@ -213,19 +213,12 @@ class CrossWOZ(datasets.GeneratorBasedBuilder):
|
|
| 213 |
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLs
|
| 214 |
# 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.
|
| 215 |
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
| 216 |
-
downloaded_files = dl_manager.download_and_extract(_URLs)
|
| 217 |
-
print(downloaded_files)
|
| 218 |
-
for _, file in downloaded_files.items():
|
| 219 |
-
print(_, file)
|
| 220 |
-
print(os.path.dirname(file))
|
| 221 |
-
print(os.listdir(os.path.dirname(file)))
|
| 222 |
-
print(os.listdir(file))
|
| 223 |
return [
|
| 224 |
datasets.SplitGenerator(
|
| 225 |
name=datasets.Split.TRAIN,
|
| 226 |
# These kwargs will be passed to _generate_examples
|
| 227 |
gen_kwargs={
|
| 228 |
-
"filepath":
|
| 229 |
"split": "train",
|
| 230 |
},
|
| 231 |
),
|
|
@@ -233,7 +226,7 @@ class CrossWOZ(datasets.GeneratorBasedBuilder):
|
|
| 233 |
name=datasets.Split.TEST,
|
| 234 |
# These kwargs will be passed to _generate_examples
|
| 235 |
gen_kwargs={
|
| 236 |
-
"filepath":
|
| 237 |
"split": "test"
|
| 238 |
},
|
| 239 |
),
|
|
@@ -241,7 +234,7 @@ class CrossWOZ(datasets.GeneratorBasedBuilder):
|
|
| 241 |
name=datasets.Split.VALIDATION,
|
| 242 |
# These kwargs will be passed to _generate_examples
|
| 243 |
gen_kwargs={
|
| 244 |
-
"filepath":
|
| 245 |
"split": "dev",
|
| 246 |
},
|
| 247 |
),
|
|
@@ -253,9 +246,6 @@ class CrossWOZ(datasets.GeneratorBasedBuilder):
|
|
| 253 |
""" Yields examples as (key, example) tuples. """
|
| 254 |
# This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
| 255 |
# The `key` is here for legacy reason (tfds) and is not important in itself.
|
| 256 |
-
print(filepath)
|
| 257 |
-
print(os.path.dirname(filepath))
|
| 258 |
-
print(os.listdir(os.path.dirname(filepath)))
|
| 259 |
def convert_goal(raw_goal):
|
| 260 |
goal = []
|
| 261 |
for subgoal in raw_goal:
|
|
@@ -304,4 +294,4 @@ class CrossWOZ(datasets.GeneratorBasedBuilder):
|
|
| 304 |
"messages": messages,
|
| 305 |
"final_goal": convert_goal(dialog["final_goal"])
|
| 306 |
}
|
| 307 |
-
key += 1
|
|
|
|
| 42 |
_LICENSE = "Apache License, Version 2.0"
|
| 43 |
|
| 44 |
_URLs = {
|
| 45 |
+
"train": "train.json.zip",
|
| 46 |
+
"val": "val.json.zip",
|
| 47 |
+
"test": "test.json.zip"
|
| 48 |
}
|
| 49 |
|
| 50 |
|
|
|
|
| 213 |
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLs
|
| 214 |
# 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.
|
| 215 |
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
return [
|
| 217 |
datasets.SplitGenerator(
|
| 218 |
name=datasets.Split.TRAIN,
|
| 219 |
# These kwargs will be passed to _generate_examples
|
| 220 |
gen_kwargs={
|
| 221 |
+
"filepath": _URLs["train"],
|
| 222 |
"split": "train",
|
| 223 |
},
|
| 224 |
),
|
|
|
|
| 226 |
name=datasets.Split.TEST,
|
| 227 |
# These kwargs will be passed to _generate_examples
|
| 228 |
gen_kwargs={
|
| 229 |
+
"filepath": _URLs["test"],
|
| 230 |
"split": "test"
|
| 231 |
},
|
| 232 |
),
|
|
|
|
| 234 |
name=datasets.Split.VALIDATION,
|
| 235 |
# These kwargs will be passed to _generate_examples
|
| 236 |
gen_kwargs={
|
| 237 |
+
"filepath": _URLs["val"],
|
| 238 |
"split": "dev",
|
| 239 |
},
|
| 240 |
),
|
|
|
|
| 246 |
""" Yields examples as (key, example) tuples. """
|
| 247 |
# This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
| 248 |
# The `key` is here for legacy reason (tfds) and is not important in itself.
|
|
|
|
|
|
|
|
|
|
| 249 |
def convert_goal(raw_goal):
|
| 250 |
goal = []
|
| 251 |
for subgoal in raw_goal:
|
|
|
|
| 294 |
"messages": messages,
|
| 295 |
"final_goal": convert_goal(dialog["final_goal"])
|
| 296 |
}
|
| 297 |
+
key += 1
|