ohashi56225
commited on
Commit
•
5aeb3eb
1
Parent(s):
c0cc6a5
Update jmultiwoz.py
Browse files- jmultiwoz.py +40 -43
jmultiwoz.py
CHANGED
@@ -38,7 +38,8 @@ _CITATION = """\
|
|
38 |
_DESCRIPTION = """\
|
39 |
JMultiWOZ is a large-scale Japanese multi-domain task-oriented dialogue dataset. The dataset is collected using
|
40 |
the Wizard-of-Oz (WoZ) methodology, where two human annotators simulate the user and the system. The dataset contains
|
41 |
-
4,
|
|
|
42 |
"""
|
43 |
|
44 |
# TODO: Add a link to an official homepage for the dataset here
|
@@ -51,11 +52,12 @@ _LICENSE = "CC BY-ND 4.0"
|
|
51 |
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
52 |
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
53 |
_URLS = {
|
54 |
-
"original_zip": "https://github.com/ohashi56225/jmultiwoz-evaluation/raw/master/dataset/JMultiWOZ_1.0.zip",
|
|
|
55 |
}
|
56 |
|
57 |
|
58 |
-
def _flatten_value(values):
|
59 |
if not isinstance(values, list):
|
60 |
return values
|
61 |
flat_values = [
|
@@ -99,13 +101,13 @@ class JMultiWOZDataset(datasets.GeneratorBasedBuilder):
|
|
99 |
"slot": datasets.Value("string"),
|
100 |
"value": datasets.Value("string"),
|
101 |
}),
|
102 |
-
"db_result":
|
103 |
"candidate_entities": datasets.Sequence(datasets.Value("string")),
|
104 |
"active_entity": datasets.Sequence({
|
105 |
"slot": datasets.Value("string"),
|
106 |
"value": datasets.Value("string"),
|
107 |
})
|
108 |
-
}
|
109 |
"book_result": datasets.Sequence({
|
110 |
"domain": datasets.Value("string"),
|
111 |
"success": datasets.Value("string"),
|
@@ -152,7 +154,6 @@ class JMultiWOZDataset(datasets.GeneratorBasedBuilder):
|
|
152 |
# These kwargs will be passed to _generate_examples
|
153 |
gen_kwargs={
|
154 |
"dialogues": [dialogues[dialogue_name] for dialogue_name in split_list["train"]],
|
155 |
-
"split": "train",
|
156 |
},
|
157 |
),
|
158 |
datasets.SplitGenerator(
|
@@ -160,7 +161,6 @@ class JMultiWOZDataset(datasets.GeneratorBasedBuilder):
|
|
160 |
# These kwargs will be passed to _generate_examples
|
161 |
gen_kwargs={
|
162 |
"dialogues": [dialogues[dialogue_name] for dialogue_name in split_list["dev"]],
|
163 |
-
"split": "dev",
|
164 |
},
|
165 |
),
|
166 |
datasets.SplitGenerator(
|
@@ -168,13 +168,12 @@ class JMultiWOZDataset(datasets.GeneratorBasedBuilder):
|
|
168 |
# These kwargs will be passed to _generate_examples
|
169 |
gen_kwargs={
|
170 |
"dialogues": [dialogues[dialogue_name] for dialogue_name in split_list["test"]],
|
171 |
-
"split": "test"
|
172 |
},
|
173 |
),
|
174 |
]
|
175 |
|
176 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
177 |
-
def _generate_examples(self, dialogues
|
178 |
# TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
179 |
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
180 |
|
@@ -216,48 +215,46 @@ class JMultiWOZDataset(datasets.GeneratorBasedBuilder):
|
|
216 |
"dialogue_state": {
|
217 |
"belief_state": [],
|
218 |
"book_state": [],
|
219 |
-
"db_result":
|
220 |
"book_result": [],
|
221 |
},
|
222 |
}
|
223 |
-
if turn["speaker"] == "
|
224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
"slot": slot,
|
231 |
-
"value": value,
|
232 |
-
})
|
233 |
-
|
234 |
-
|
235 |
-
for
|
236 |
-
example_turn["dialogue_state"]["
|
237 |
"domain": domain,
|
238 |
-
"
|
239 |
-
"
|
240 |
})
|
241 |
|
242 |
-
candidate_entities = turn["dialogue_state"]["db_result"]["candidate_entities"]
|
243 |
-
active_entity = turn["dialogue_state"]["db_result"]["active_entity"]
|
244 |
-
if not active_entity:
|
245 |
-
active_entity = {}
|
246 |
-
example_turn["dialogue_state"]["db_result"].append({
|
247 |
-
"candidate_entities":candidate_entities,
|
248 |
-
"active_entity": [{
|
249 |
-
"slot": slot,
|
250 |
-
"value": _flatten_value(value),
|
251 |
-
} for slot, value in active_entity.items()]
|
252 |
-
})
|
253 |
-
|
254 |
-
for domain, result in turn["dialogue_state"]["book_result"].items():
|
255 |
-
example_turn["dialogue_state"]["book_result"].append({
|
256 |
-
"domain": domain,
|
257 |
-
"success": result["success"],
|
258 |
-
"ref": result["ref"],
|
259 |
-
})
|
260 |
-
|
261 |
example["turns"].append(example_turn)
|
262 |
|
263 |
yield id_, example
|
|
|
38 |
_DESCRIPTION = """\
|
39 |
JMultiWOZ is a large-scale Japanese multi-domain task-oriented dialogue dataset. The dataset is collected using
|
40 |
the Wizard-of-Oz (WoZ) methodology, where two human annotators simulate the user and the system. The dataset contains
|
41 |
+
4,246 dialogues across 6 domains, including restaurant, hotel, attraction, shopping, taxi, and weather. Available
|
42 |
+
annotations include user goal, dialogue state, and utterances.
|
43 |
"""
|
44 |
|
45 |
# TODO: Add a link to an official homepage for the dataset here
|
|
|
52 |
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
53 |
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
54 |
_URLS = {
|
55 |
+
# "original_zip": "https://github.com/ohashi56225/jmultiwoz-evaluation/raw/master/dataset/JMultiWOZ_1.0.zip",
|
56 |
+
"original_zip": "JMultiWOZ_1.0.zip"
|
57 |
}
|
58 |
|
59 |
|
60 |
+
def _flatten_value(values) -> str:
|
61 |
if not isinstance(values, list):
|
62 |
return values
|
63 |
flat_values = [
|
|
|
101 |
"slot": datasets.Value("string"),
|
102 |
"value": datasets.Value("string"),
|
103 |
}),
|
104 |
+
"db_result": {
|
105 |
"candidate_entities": datasets.Sequence(datasets.Value("string")),
|
106 |
"active_entity": datasets.Sequence({
|
107 |
"slot": datasets.Value("string"),
|
108 |
"value": datasets.Value("string"),
|
109 |
})
|
110 |
+
},
|
111 |
"book_result": datasets.Sequence({
|
112 |
"domain": datasets.Value("string"),
|
113 |
"success": datasets.Value("string"),
|
|
|
154 |
# These kwargs will be passed to _generate_examples
|
155 |
gen_kwargs={
|
156 |
"dialogues": [dialogues[dialogue_name] for dialogue_name in split_list["train"]],
|
|
|
157 |
},
|
158 |
),
|
159 |
datasets.SplitGenerator(
|
|
|
161 |
# These kwargs will be passed to _generate_examples
|
162 |
gen_kwargs={
|
163 |
"dialogues": [dialogues[dialogue_name] for dialogue_name in split_list["dev"]],
|
|
|
164 |
},
|
165 |
),
|
166 |
datasets.SplitGenerator(
|
|
|
168 |
# These kwargs will be passed to _generate_examples
|
169 |
gen_kwargs={
|
170 |
"dialogues": [dialogues[dialogue_name] for dialogue_name in split_list["test"]],
|
|
|
171 |
},
|
172 |
),
|
173 |
]
|
174 |
|
175 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
176 |
+
def _generate_examples(self, dialogues):
|
177 |
# TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
178 |
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
179 |
|
|
|
215 |
"dialogue_state": {
|
216 |
"belief_state": [],
|
217 |
"book_state": [],
|
218 |
+
"db_result": {},
|
219 |
"book_result": [],
|
220 |
},
|
221 |
}
|
222 |
+
if turn["speaker"] == "SYSTEM":
|
223 |
+
for domain, slots in turn["dialogue_state"]["belief_state"].items():
|
224 |
+
for slot, value in slots.items():
|
225 |
+
example_turn["dialogue_state"]["belief_state"].append({
|
226 |
+
"domain": domain,
|
227 |
+
"slot": slot,
|
228 |
+
"value": value,
|
229 |
+
})
|
230 |
|
231 |
+
for domain, slots in turn["dialogue_state"]["book_state"].items():
|
232 |
+
for slot, value in slots.items():
|
233 |
+
example_turn["dialogue_state"]["book_state"].append({
|
234 |
+
"domain": domain,
|
235 |
+
"slot": slot,
|
236 |
+
"value": value,
|
237 |
+
})
|
238 |
+
|
239 |
+
candidate_entities = turn["dialogue_state"]["db_result"]["candidate_entities"]
|
240 |
+
active_entity = turn["dialogue_state"]["db_result"]["active_entity"]
|
241 |
+
if not active_entity:
|
242 |
+
active_entity = {}
|
243 |
+
example_turn["dialogue_state"]["db_result"] = {
|
244 |
+
"candidate_entities":candidate_entities,
|
245 |
+
"active_entity": [{
|
246 |
"slot": slot,
|
247 |
+
"value": _flatten_value(value),
|
248 |
+
} for slot, value in active_entity.items()]
|
249 |
+
}
|
250 |
+
|
251 |
+
for domain, result in turn["dialogue_state"]["book_result"].items():
|
252 |
+
example_turn["dialogue_state"]["book_result"].append({
|
253 |
"domain": domain,
|
254 |
+
"success": result["success"],
|
255 |
+
"ref": result["ref"],
|
256 |
})
|
257 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
example["turns"].append(example_turn)
|
259 |
|
260 |
yield id_, example
|