Datasets:
Commit
•
9c8827c
0
Parent(s):
Update files from the datasets library (from 1.2.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.2.0
- .gitattributes +27 -0
- README.md +243 -0
- dataset_infos.json +1 -0
- dummy/all_dialogues/0.0.0/dummy_data.zip +3 -0
- dummy/all_knowledge_base/0.0.0/dummy_data.zip +3 -0
- dummy/film_dialogues/0.0.0/dummy_data.zip +3 -0
- dummy/film_knowledge_base/0.0.0/dummy_data.zip +3 -0
- dummy/music_dialogues/0.0.0/dummy_data.zip +3 -0
- dummy/music_knowledge_base/0.0.0/dummy_data.zip +3 -0
- dummy/travel_dialogues/0.0.0/dummy_data.zip +3 -0
- dummy/travel_knowledge_base/0.0.0/dummy_data.zip +3 -0
- kd_conv.py +202 -0
.gitattributes
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
20 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,243 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
- crowdsourced
|
4 |
+
- machine-generated
|
5 |
+
language_creators:
|
6 |
+
- crowdsourced
|
7 |
+
languages:
|
8 |
+
- zh
|
9 |
+
licenses:
|
10 |
+
- apache-2-0
|
11 |
+
multilinguality:
|
12 |
+
- monolingual
|
13 |
+
size_categories:
|
14 |
+
- 1K<n<10K
|
15 |
+
source_datasets:
|
16 |
+
- original
|
17 |
+
task_categories:
|
18 |
+
- sequence-modeling
|
19 |
+
task_ids:
|
20 |
+
- dialogue-modeling
|
21 |
+
- other-multi-turn
|
22 |
+
---
|
23 |
+
|
24 |
+
# Dataset Card for KdConv
|
25 |
+
|
26 |
+
## Table of Contents
|
27 |
+
- [Dataset Description](#dataset-description)
|
28 |
+
- [Dataset Summary](#dataset-summary)
|
29 |
+
- [Supported Tasks](#supported-tasks-and-leaderboards)
|
30 |
+
- [Languages](#languages)
|
31 |
+
- [Dataset Structure](#dataset-structure)
|
32 |
+
- [Data Instances](#data-instances)
|
33 |
+
- [Data Fields](#data-fields)
|
34 |
+
- [Data Splits](#data-splits)
|
35 |
+
- [Dataset Creation](#dataset-creation)
|
36 |
+
- [Curation Rationale](#curation-rationale)
|
37 |
+
- [Source Data](#source-data)
|
38 |
+
- [Annotations](#annotations)
|
39 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
40 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
41 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
42 |
+
- [Discussion of Biases](#discussion-of-biases)
|
43 |
+
- [Other Known Limitations](#other-known-limitations)
|
44 |
+
- [Additional Information](#additional-information)
|
45 |
+
- [Dataset Curators](#dataset-curators)
|
46 |
+
- [Licensing Information](#licensing-information)
|
47 |
+
- [Citation Information](#citation-information)
|
48 |
+
|
49 |
+
## Dataset Description
|
50 |
+
|
51 |
+
- **Repository:** [Github](https://github.com/thu-coai/KdConv)
|
52 |
+
- **Paper:** [{K}d{C}onv: A {C}hinese Multi-domain Dialogue Dataset Towards Multi-turn Knowledge-driven Conversation](https://www.aclweb.org/anthology/2020.acl-main.635.pdf)
|
53 |
+
|
54 |
+
### Dataset Summary
|
55 |
+
|
56 |
+
KdConv is a Chinese multi-domain Knowledge-driven Conversionsation dataset, grounding the topics in multi-turn
|
57 |
+
conversations to knowledge graphs. KdConv contains 4.5K conversations from three domains (film, music, and travel),
|
58 |
+
and 86K utterances with an average turn number of 19.0. These conversations contain in-depth discussions on related
|
59 |
+
topics and natural transition between multiple topics, while the corpus can also used for exploration of transfer
|
60 |
+
learning and domain adaptation.
|
61 |
+
|
62 |
+
### Supported Tasks and Leaderboards
|
63 |
+
|
64 |
+
This dataset can be leveraged for dialogue modelling tasks involving multi-turn and Knowledge base setup.
|
65 |
+
|
66 |
+
### Languages
|
67 |
+
|
68 |
+
This dataset has only Chinese Language.
|
69 |
+
|
70 |
+
## Dataset Structure
|
71 |
+
|
72 |
+
### Data Instances
|
73 |
+
|
74 |
+
Each data instance is a multi-turn conversation between 2 people with annotated knowledge base data used while talking
|
75 |
+
, e.g.:
|
76 |
+
```
|
77 |
+
{
|
78 |
+
"messages": [
|
79 |
+
{
|
80 |
+
"message": "对《我喜欢上你时的内心活动》这首歌有了解吗?"
|
81 |
+
},
|
82 |
+
{
|
83 |
+
"attrs": [
|
84 |
+
{
|
85 |
+
"attrname": "Information",
|
86 |
+
"attrvalue": "《我喜欢上你时的内心活动》是由韩寒填词,陈光荣作曲,陈绮贞演唱的歌曲,作为电影《喜欢你》的主题曲于2017年4月10日首发。2018年,该曲先后提名第37届香港电影金像奖最佳原创电影歌曲奖、第7届阿比鹿音乐奖流行单曲奖。",
|
87 |
+
"name": "我喜欢上你时的内心活动"
|
88 |
+
}
|
89 |
+
],
|
90 |
+
"message": "有些了解,是电影《喜欢你》的主题曲。"
|
91 |
+
},
|
92 |
+
...
|
93 |
+
{
|
94 |
+
"attrs": [
|
95 |
+
{
|
96 |
+
"attrname": "代表作品",
|
97 |
+
"attrvalue": "旅行的意义",
|
98 |
+
"name": "陈绮贞"
|
99 |
+
},
|
100 |
+
{
|
101 |
+
"attrname": "代表作品",
|
102 |
+
"attrvalue": "时间的歌",
|
103 |
+
"name": "陈绮贞"
|
104 |
+
}
|
105 |
+
],
|
106 |
+
"message": "我还知道《旅行的意义》与《时间的歌》,都算是她的代表作。"
|
107 |
+
},
|
108 |
+
{
|
109 |
+
"message": "好,有时间我找出来听听。"
|
110 |
+
}
|
111 |
+
],
|
112 |
+
"name": "我喜欢上你时的内心活动"
|
113 |
+
}
|
114 |
+
```
|
115 |
+
|
116 |
+
The corresponding entries in Knowledge base is a dictionary with list of knowledge base triplets (head entity
|
117 |
+
, relationship, tail entity), e.g.:
|
118 |
+
```
|
119 |
+
"忽然之间": [
|
120 |
+
[
|
121 |
+
"忽然之间",
|
122 |
+
"Information",
|
123 |
+
"《忽然之间》是歌手 莫文蔚演唱的歌曲,由 周耀辉, 李卓雄填词, 林健华谱曲,收录在莫文蔚1999年发行专辑《 就是莫文蔚》里。"
|
124 |
+
],
|
125 |
+
[
|
126 |
+
"忽然之间",
|
127 |
+
"谱曲",
|
128 |
+
"林健华"
|
129 |
+
]
|
130 |
+
...
|
131 |
+
]
|
132 |
+
```
|
133 |
+
|
134 |
+
### Data Fields
|
135 |
+
|
136 |
+
Conversation data fields:
|
137 |
+
- `name`: the starting topic (entity) of the conversation
|
138 |
+
- `domain`: the domain this sample belongs to. Categorical value among `{travel, film, music}`
|
139 |
+
- `messages`: list of all the turns in the dialogue. For each turn:
|
140 |
+
- `message`: the utterance
|
141 |
+
- `attrs`: list of knowledge graph triplets referred by the utterance. For each triplet:
|
142 |
+
- `name`: the head entity
|
143 |
+
- `attrname`: the relation
|
144 |
+
- `attrvalue`: the tail entity
|
145 |
+
|
146 |
+
Knowledge Base data fields:
|
147 |
+
- `head_entity`: the head entity
|
148 |
+
- `kb_triplets`: list of corresponding triplets
|
149 |
+
- `domain`: the domain this sample belongs to. Categorical value among `{travel, film, music}`
|
150 |
+
|
151 |
+
### Data Splits
|
152 |
+
|
153 |
+
The conversation dataset is split into a `train`, `validation`, and `test` split with the following sizes:
|
154 |
+
|
155 |
+
| | train | dev | test |
|
156 |
+
| ----- | ------ | ----- | ---- |
|
157 |
+
| travel | 1200 | 1200 | 1200 |
|
158 |
+
| film | 1200 | 150 | 150 |
|
159 |
+
| music | 1200 | 150 | 150 |
|
160 |
+
| all | 3600 | 450 | 450 |
|
161 |
+
|
162 |
+
The Knowledge base dataset is having only train split with following sizes:
|
163 |
+
|
164 |
+
| | train |
|
165 |
+
| ----- | ------ |
|
166 |
+
| travel | 1154 |
|
167 |
+
| film | 8090 |
|
168 |
+
| music | 4441 |
|
169 |
+
| all | 13685 |
|
170 |
+
|
171 |
+
## Dataset Creation
|
172 |
+
|
173 |
+
### Curation Rationale
|
174 |
+
|
175 |
+
[More Information Needed]
|
176 |
+
|
177 |
+
### Source Data
|
178 |
+
|
179 |
+
#### Initial Data Collection and Normalization
|
180 |
+
|
181 |
+
[More Information Needed]
|
182 |
+
|
183 |
+
#### Who are the source language producers?
|
184 |
+
|
185 |
+
[More Information Needed]
|
186 |
+
|
187 |
+
### Annotations
|
188 |
+
|
189 |
+
#### Annotation process
|
190 |
+
|
191 |
+
[More Information Needed]
|
192 |
+
|
193 |
+
#### Who are the annotators?
|
194 |
+
|
195 |
+
[More Information Needed]
|
196 |
+
|
197 |
+
### Personal and Sensitive Information
|
198 |
+
|
199 |
+
[More Information Needed]
|
200 |
+
|
201 |
+
## Considerations for Using the Data
|
202 |
+
|
203 |
+
### Social Impact of Dataset
|
204 |
+
|
205 |
+
[More Information Needed]
|
206 |
+
|
207 |
+
### Discussion of Biases
|
208 |
+
|
209 |
+
[More Information Needed]
|
210 |
+
|
211 |
+
### Other Known Limitations
|
212 |
+
|
213 |
+
[More Information Needed]
|
214 |
+
|
215 |
+
## Additional Information
|
216 |
+
|
217 |
+
### Dataset Curators
|
218 |
+
|
219 |
+
[More Information Needed]
|
220 |
+
|
221 |
+
### Licensing Information
|
222 |
+
|
223 |
+
Apache License 2.0
|
224 |
+
|
225 |
+
### Citation Information
|
226 |
+
```
|
227 |
+
@inproceedings{zhou-etal-2020-kdconv,
|
228 |
+
title = "{K}d{C}onv: A {C}hinese Multi-domain Dialogue Dataset Towards Multi-turn Knowledge-driven Conversation",
|
229 |
+
author = "Zhou, Hao and
|
230 |
+
Zheng, Chujie and
|
231 |
+
Huang, Kaili and
|
232 |
+
Huang, Minlie and
|
233 |
+
Zhu, Xiaoyan",
|
234 |
+
booktitle = "Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics",
|
235 |
+
month = jul,
|
236 |
+
year = "2020",
|
237 |
+
address = "Online",
|
238 |
+
publisher = "Association for Computational Linguistics",
|
239 |
+
url = "https://www.aclweb.org/anthology/2020.acl-main.635",
|
240 |
+
doi = "10.18653/v1/2020.acl-main.635",
|
241 |
+
pages = "7098--7108",
|
242 |
+
}
|
243 |
+
```
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"travel_dialogues": {"description": "KdConv is a Chinese multi-domain Knowledge-driven Conversionsation dataset, grounding the topics in multi-turn conversations to knowledge graphs. KdConv contains 4.5K conversations from three domains (film, music, and travel), and 86K utterances with an average turn number of 19.0. These conversations contain in-depth discussions on related topics and natural transition between multiple topics, while the corpus can also used for exploration of transfer learning and domain adaptation. \n", "citation": "@inproceedings{zhou-etal-2020-kdconv,\n title = \"{K}d{C}onv: A {C}hinese Multi-domain Dialogue Dataset Towards Multi-turn Knowledge-driven Conversation\",\n author = \"Zhou, Hao and\n Zheng, Chujie and\n Huang, Kaili and\n Huang, Minlie and\n Zhu, Xiaoyan\",\n booktitle = \"Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics\",\n month = jul,\n year = \"2020\",\n address = \"Online\",\n publisher = \"Association for Computational Linguistics\",\n url = \"https://www.aclweb.org/anthology/2020.acl-main.635\",\n doi = \"10.18653/v1/2020.acl-main.635\",\n pages = \"7098--7108\",\n}\n", "homepage": "https://github.com/thu-coai/KdConv", "license": "Apache License 2.0", "features": {"messages": {"feature": {"message": {"dtype": "string", "id": null, "_type": "Value"}, "attrs": {"feature": {"attrname": {"dtype": "string", "id": null, "_type": "Value"}, "attrvalue": {"dtype": "string", "id": null, "_type": "Value"}, "name": {"dtype": "string", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}}, "length": -1, "id": null, "_type": "Sequence"}, "name": {"dtype": "string", "id": null, "_type": "Value"}, "domain": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "kd_conv", "config_name": "travel_dialogues", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 3241550, "num_examples": 1200, "dataset_name": "kd_conv"}, "test": {"name": "test", "num_bytes": 793883, "num_examples": 150, "dataset_name": "kd_conv"}, "validation": {"name": "validation", "num_bytes": 617177, "num_examples": 150, "dataset_name": "kd_conv"}}, "download_checksums": {"https://github.com/thu-coai/KdConv/archive/master.zip": {"num_bytes": 11037768, "checksum": "a083dd60846e75e55e792dd85c392a7119f68b8f06a50eeb8c3b9c3e256ef8fc"}}, "download_size": 11037768, "post_processing_size": null, "dataset_size": 4652610, "size_in_bytes": 15690378}, "travel_knowledge_base": {"description": "KdConv is a Chinese multi-domain Knowledge-driven Conversionsation dataset, grounding the topics in multi-turn conversations to knowledge graphs. KdConv contains 4.5K conversations from three domains (film, music, and travel), and 86K utterances with an average turn number of 19.0. These conversations contain in-depth discussions on related topics and natural transition between multiple topics, while the corpus can also used for exploration of transfer learning and domain adaptation. \n", "citation": "@inproceedings{zhou-etal-2020-kdconv,\n title = \"{K}d{C}onv: A {C}hinese Multi-domain Dialogue Dataset Towards Multi-turn Knowledge-driven Conversation\",\n author = \"Zhou, Hao and\n Zheng, Chujie and\n Huang, Kaili and\n Huang, Minlie and\n Zhu, Xiaoyan\",\n booktitle = \"Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics\",\n month = jul,\n year = \"2020\",\n address = \"Online\",\n publisher = \"Association for Computational Linguistics\",\n url = \"https://www.aclweb.org/anthology/2020.acl-main.635\",\n doi = \"10.18653/v1/2020.acl-main.635\",\n pages = \"7098--7108\",\n}\n", "homepage": "https://github.com/thu-coai/KdConv", "license": "Apache License 2.0", "features": {"head_entity": {"dtype": "string", "id": null, "_type": "Value"}, "kb_triplets": {"feature": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "domain": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "kd_conv", "config_name": "travel_knowledge_base", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 1517024, "num_examples": 1154, "dataset_name": "kd_conv"}}, "download_checksums": {"https://github.com/thu-coai/KdConv/archive/master.zip": {"num_bytes": 11037768, "checksum": "a083dd60846e75e55e792dd85c392a7119f68b8f06a50eeb8c3b9c3e256ef8fc"}}, "download_size": 11037768, "post_processing_size": null, "dataset_size": 1517024, "size_in_bytes": 12554792}, "music_dialogues": {"description": "KdConv is a Chinese multi-domain Knowledge-driven Conversionsation dataset, grounding the topics in multi-turn conversations to knowledge graphs. KdConv contains 4.5K conversations from three domains (film, music, and travel), and 86K utterances with an average turn number of 19.0. These conversations contain in-depth discussions on related topics and natural transition between multiple topics, while the corpus can also used for exploration of transfer learning and domain adaptation. \n", "citation": "@inproceedings{zhou-etal-2020-kdconv,\n title = \"{K}d{C}onv: A {C}hinese Multi-domain Dialogue Dataset Towards Multi-turn Knowledge-driven Conversation\",\n author = \"Zhou, Hao and\n Zheng, Chujie and\n Huang, Kaili and\n Huang, Minlie and\n Zhu, Xiaoyan\",\n booktitle = \"Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics\",\n month = jul,\n year = \"2020\",\n address = \"Online\",\n publisher = \"Association for Computational Linguistics\",\n url = \"https://www.aclweb.org/anthology/2020.acl-main.635\",\n doi = \"10.18653/v1/2020.acl-main.635\",\n pages = \"7098--7108\",\n}\n", "homepage": "https://github.com/thu-coai/KdConv", "license": "Apache License 2.0", "features": {"messages": {"feature": {"message": {"dtype": "string", "id": null, "_type": "Value"}, "attrs": {"feature": {"attrname": {"dtype": "string", "id": null, "_type": "Value"}, "attrvalue": {"dtype": "string", "id": null, "_type": "Value"}, "name": {"dtype": "string", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}}, "length": -1, "id": null, "_type": "Sequence"}, "name": {"dtype": "string", "id": null, "_type": "Value"}, "domain": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "kd_conv", "config_name": "music_dialogues", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 3006192, "num_examples": 1200, "dataset_name": "kd_conv"}, "test": {"name": "test", "num_bytes": 801012, "num_examples": 150, "dataset_name": "kd_conv"}, "validation": {"name": "validation", "num_bytes": 633905, "num_examples": 150, "dataset_name": "kd_conv"}}, "download_checksums": {"https://github.com/thu-coai/KdConv/archive/master.zip": {"num_bytes": 11037768, "checksum": "a083dd60846e75e55e792dd85c392a7119f68b8f06a50eeb8c3b9c3e256ef8fc"}}, "download_size": 11037768, "post_processing_size": null, "dataset_size": 4441109, "size_in_bytes": 15478877}, "music_knowledge_base": {"description": "KdConv is a Chinese multi-domain Knowledge-driven Conversionsation dataset, grounding the topics in multi-turn conversations to knowledge graphs. KdConv contains 4.5K conversations from three domains (film, music, and travel), and 86K utterances with an average turn number of 19.0. These conversations contain in-depth discussions on related topics and natural transition between multiple topics, while the corpus can also used for exploration of transfer learning and domain adaptation. \n", "citation": "@inproceedings{zhou-etal-2020-kdconv,\n title = \"{K}d{C}onv: A {C}hinese Multi-domain Dialogue Dataset Towards Multi-turn Knowledge-driven Conversation\",\n author = \"Zhou, Hao and\n Zheng, Chujie and\n Huang, Kaili and\n Huang, Minlie and\n Zhu, Xiaoyan\",\n booktitle = \"Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics\",\n month = jul,\n year = \"2020\",\n address = \"Online\",\n publisher = \"Association for Computational Linguistics\",\n url = \"https://www.aclweb.org/anthology/2020.acl-main.635\",\n doi = \"10.18653/v1/2020.acl-main.635\",\n pages = \"7098--7108\",\n}\n", "homepage": "https://github.com/thu-coai/KdConv", "license": "Apache License 2.0", "features": {"head_entity": {"dtype": "string", "id": null, "_type": "Value"}, "kb_triplets": {"feature": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "domain": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "kd_conv", "config_name": "music_knowledge_base", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 5980643, "num_examples": 4441, "dataset_name": "kd_conv"}}, "download_checksums": {"https://github.com/thu-coai/KdConv/archive/master.zip": {"num_bytes": 11037768, "checksum": "a083dd60846e75e55e792dd85c392a7119f68b8f06a50eeb8c3b9c3e256ef8fc"}}, "download_size": 11037768, "post_processing_size": null, "dataset_size": 5980643, "size_in_bytes": 17018411}, "film_dialogues": {"description": "KdConv is a Chinese multi-domain Knowledge-driven Conversionsation dataset, grounding the topics in multi-turn conversations to knowledge graphs. KdConv contains 4.5K conversations from three domains (film, music, and travel), and 86K utterances with an average turn number of 19.0. These conversations contain in-depth discussions on related topics and natural transition between multiple topics, while the corpus can also used for exploration of transfer learning and domain adaptation. \n", "citation": "@inproceedings{zhou-etal-2020-kdconv,\n title = \"{K}d{C}onv: A {C}hinese Multi-domain Dialogue Dataset Towards Multi-turn Knowledge-driven Conversation\",\n author = \"Zhou, Hao and\n Zheng, Chujie and\n Huang, Kaili and\n Huang, Minlie and\n Zhu, Xiaoyan\",\n booktitle = \"Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics\",\n month = jul,\n year = \"2020\",\n address = \"Online\",\n publisher = \"Association for Computational Linguistics\",\n url = \"https://www.aclweb.org/anthology/2020.acl-main.635\",\n doi = \"10.18653/v1/2020.acl-main.635\",\n pages = \"7098--7108\",\n}\n", "homepage": "https://github.com/thu-coai/KdConv", "license": "Apache License 2.0", "features": {"messages": {"feature": {"message": {"dtype": "string", "id": null, "_type": "Value"}, "attrs": {"feature": {"attrname": {"dtype": "string", "id": null, "_type": "Value"}, "attrvalue": {"dtype": "string", "id": null, "_type": "Value"}, "name": {"dtype": "string", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}}, "length": -1, "id": null, "_type": "Sequence"}, "name": {"dtype": "string", "id": null, "_type": "Value"}, "domain": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "kd_conv", "config_name": "film_dialogues", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 4867659, "num_examples": 1200, "dataset_name": "kd_conv"}, "test": {"name": "test", "num_bytes": 956995, "num_examples": 150, "dataset_name": "kd_conv"}, "validation": {"name": "validation", "num_bytes": 884232, "num_examples": 150, "dataset_name": "kd_conv"}}, "download_checksums": {"https://github.com/thu-coai/KdConv/archive/master.zip": {"num_bytes": 11037768, "checksum": "a083dd60846e75e55e792dd85c392a7119f68b8f06a50eeb8c3b9c3e256ef8fc"}}, "download_size": 11037768, "post_processing_size": null, "dataset_size": 6708886, "size_in_bytes": 17746654}, "film_knowledge_base": {"description": "KdConv is a Chinese multi-domain Knowledge-driven Conversionsation dataset, grounding the topics in multi-turn conversations to knowledge graphs. KdConv contains 4.5K conversations from three domains (film, music, and travel), and 86K utterances with an average turn number of 19.0. These conversations contain in-depth discussions on related topics and natural transition between multiple topics, while the corpus can also used for exploration of transfer learning and domain adaptation. \n", "citation": "@inproceedings{zhou-etal-2020-kdconv,\n title = \"{K}d{C}onv: A {C}hinese Multi-domain Dialogue Dataset Towards Multi-turn Knowledge-driven Conversation\",\n author = \"Zhou, Hao and\n Zheng, Chujie and\n Huang, Kaili and\n Huang, Minlie and\n Zhu, Xiaoyan\",\n booktitle = \"Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics\",\n month = jul,\n year = \"2020\",\n address = \"Online\",\n publisher = \"Association for Computational Linguistics\",\n url = \"https://www.aclweb.org/anthology/2020.acl-main.635\",\n doi = \"10.18653/v1/2020.acl-main.635\",\n pages = \"7098--7108\",\n}\n", "homepage": "https://github.com/thu-coai/KdConv", "license": "Apache License 2.0", "features": {"head_entity": {"dtype": "string", "id": null, "_type": "Value"}, "kb_triplets": {"feature": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "domain": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "kd_conv", "config_name": "film_knowledge_base", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 10500882, "num_examples": 8090, "dataset_name": "kd_conv"}}, "download_checksums": {"https://github.com/thu-coai/KdConv/archive/master.zip": {"num_bytes": 11037768, "checksum": "a083dd60846e75e55e792dd85c392a7119f68b8f06a50eeb8c3b9c3e256ef8fc"}}, "download_size": 11037768, "post_processing_size": null, "dataset_size": 10500882, "size_in_bytes": 21538650}, "all_dialogues": {"description": "KdConv is a Chinese multi-domain Knowledge-driven Conversionsation dataset, grounding the topics in multi-turn conversations to knowledge graphs. KdConv contains 4.5K conversations from three domains (film, music, and travel), and 86K utterances with an average turn number of 19.0. These conversations contain in-depth discussions on related topics and natural transition between multiple topics, while the corpus can also used for exploration of transfer learning and domain adaptation. \n", "citation": "@inproceedings{zhou-etal-2020-kdconv,\n title = \"{K}d{C}onv: A {C}hinese Multi-domain Dialogue Dataset Towards Multi-turn Knowledge-driven Conversation\",\n author = \"Zhou, Hao and\n Zheng, Chujie and\n Huang, Kaili and\n Huang, Minlie and\n Zhu, Xiaoyan\",\n booktitle = \"Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics\",\n month = jul,\n year = \"2020\",\n address = \"Online\",\n publisher = \"Association for Computational Linguistics\",\n url = \"https://www.aclweb.org/anthology/2020.acl-main.635\",\n doi = \"10.18653/v1/2020.acl-main.635\",\n pages = \"7098--7108\",\n}\n", "homepage": "https://github.com/thu-coai/KdConv", "license": "Apache License 2.0", "features": {"messages": {"feature": {"message": {"dtype": "string", "id": null, "_type": "Value"}, "attrs": {"feature": {"attrname": {"dtype": "string", "id": null, "_type": "Value"}, "attrvalue": {"dtype": "string", "id": null, "_type": "Value"}, "name": {"dtype": "string", "id": null, "_type": "Value"}}, "length": -1, "id": null, "_type": "Sequence"}}, "length": -1, "id": null, "_type": "Sequence"}, "name": {"dtype": "string", "id": null, "_type": "Value"}, "domain": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "kd_conv", "config_name": "all_dialogues", "version": {"version_str": "0.0.0", "description": null, "major": 0, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 11115313, "num_examples": 3600, "dataset_name": "kd_conv"}, "test": {"name": "test", "num_bytes": 2551802, "num_examples": 450, "dataset_name": "kd_conv"}, "validation": {"name": "validation", "num_bytes": 2135226, "num_examples": 450, "dataset_name": "kd_conv"}}, "download_checksums": {"https://github.com/thu-coai/KdConv/archive/master.zip": {"num_bytes": 11037768, "checksum": "a083dd60846e75e55e792dd85c392a7119f68b8f06a50eeb8c3b9c3e256ef8fc"}}, "download_size": 11037768, "post_processing_size": null, "dataset_size": 15802341, "size_in_bytes": 26840109}, "all_knowledge_base": {"description": "KdConv is a Chinese multi-domain Knowledge-driven Conversionsation dataset, grounding the topics in multi-turn conversations to knowledge graphs. KdConv contains 4.5K conversations from three domains (film, music, and travel), and 86K utterances with an average turn number of 19.0. These conversations contain in-depth discussions on related topics and natural transition between multiple topics, while the corpus can also used for exploration of transfer learning and domain adaptation. \n", "citation": "@inproceedings{zhou-etal-2020-kdconv,\n title = \"{K}d{C}onv: A {C}hinese Multi-domain Dialogue Dataset Towards Multi-turn Knowledge-driven Conversation\",\n author = \"Zhou, Hao and\n Zheng, Chujie and\n Huang, Kaili and\n Huang, Minlie and\n Zhu, Xiaoyan\",\n booktitle = \"Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics\",\n month = jul,\n year = \"2020\",\n address = \"Online\",\n publisher = \"Association for Computational Linguistics\",\n url = \"https://www.aclweb.org/anthology/2020.acl-main.635\",\n doi = \"10.18653/v1/2020.acl-main.635\",\n pages = \"7098--7108\",\n}\n", "homepage": "https://github.com/thu-coai/KdConv", "license": "Apache License 2.0", "features": {"head_entity": {"dtype": "string", "id": null, "_type": "Value"}, "kb_triplets": {"feature": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "length": -1, "id": null, "_type": "Sequence"}, "domain": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "kd_conv", "config_name": "all_knowledge_base", "version": "0.0.0", "splits": {"train": {"name": "train", "num_bytes": 17998529, "num_examples": 13685, "dataset_name": "kd_conv"}}, "download_checksums": {"https://github.com/thu-coai/KdConv/archive/master.zip": {"num_bytes": 11037768, "checksum": "a083dd60846e75e55e792dd85c392a7119f68b8f06a50eeb8c3b9c3e256ef8fc"}}, "download_size": 11037768, "post_processing_size": null, "dataset_size": 17998529, "size_in_bytes": 29036297}}
|
dummy/all_dialogues/0.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:16e4a6a3e185ab1c2397f33d37f9c345a471a77e52cc8e6b32163ba659dd5a17
|
3 |
+
size 13724
|
dummy/all_knowledge_base/0.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e40b6aa5c3bab216a6970f9ef9079ec1951b2930aa6bff78f21e4c511344485c
|
3 |
+
size 9185
|
dummy/film_dialogues/0.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cf22818b495d15db87e18a90e8fe9e2eee1c9db86e2ae2c8bf9a6de0580a55ed
|
3 |
+
size 2467
|
dummy/film_knowledge_base/0.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:26d79370f8e549cae0a31527f8d73653dfc00104552bcb47a2ae961c6b989cd9
|
3 |
+
size 1955
|
dummy/music_dialogues/0.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f51a93b128fcdba032331cfd54afeaecfb46c1661733a9950cdb4e702b9a19bf
|
3 |
+
size 2477
|
dummy/music_knowledge_base/0.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:598ae7c2c7741d0a713a01aed28e5ab57c8e150249fcc801490c0522e2178d46
|
3 |
+
size 1963
|
dummy/travel_dialogues/0.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4ee1c3e466c9ffa91baa9fe1825dc57e5808a971a80b9b7f554e53512457df0c
|
3 |
+
size 2487
|
dummy/travel_knowledge_base/0.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:243f5dce208b2283e409f29f7f9a3854cf738ca4c84bd8bdf2348bbc982474d8
|
3 |
+
size 1971
|
kd_conv.py
ADDED
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
"""KdConv: Chinese multi-domain Knowledge-driven Conversionsation dataset"""
|
16 |
+
|
17 |
+
from __future__ import absolute_import, division, print_function
|
18 |
+
|
19 |
+
import json
|
20 |
+
import os
|
21 |
+
|
22 |
+
import datasets
|
23 |
+
|
24 |
+
|
25 |
+
_CITATION = """\
|
26 |
+
@inproceedings{zhou-etal-2020-kdconv,
|
27 |
+
title = "{K}d{C}onv: A {C}hinese Multi-domain Dialogue Dataset Towards Multi-turn Knowledge-driven Conversation",
|
28 |
+
author = "Zhou, Hao and
|
29 |
+
Zheng, Chujie and
|
30 |
+
Huang, Kaili and
|
31 |
+
Huang, Minlie and
|
32 |
+
Zhu, Xiaoyan",
|
33 |
+
booktitle = "Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics",
|
34 |
+
month = jul,
|
35 |
+
year = "2020",
|
36 |
+
address = "Online",
|
37 |
+
publisher = "Association for Computational Linguistics",
|
38 |
+
url = "https://www.aclweb.org/anthology/2020.acl-main.635",
|
39 |
+
doi = "10.18653/v1/2020.acl-main.635",
|
40 |
+
pages = "7098--7108",
|
41 |
+
}
|
42 |
+
"""
|
43 |
+
|
44 |
+
|
45 |
+
_DESCRIPTION = """\
|
46 |
+
KdConv is a Chinese multi-domain Knowledge-driven Conversionsation dataset, grounding the topics in multi-turn \
|
47 |
+
conversations to knowledge graphs. KdConv contains 4.5K conversations from three domains (film, music, and travel), \
|
48 |
+
and 86K utterances with an average turn number of 19.0. These conversations contain in-depth discussions on related \
|
49 |
+
topics and natural transition between multiple topics, while the corpus can also used for exploration of transfer \
|
50 |
+
learning and domain adaptation.\
|
51 |
+
"""
|
52 |
+
|
53 |
+
|
54 |
+
_HOMEPAGE = "https://github.com/thu-coai/KdConv"
|
55 |
+
|
56 |
+
|
57 |
+
_LICENSE = "Apache License 2.0"
|
58 |
+
|
59 |
+
|
60 |
+
_URL = "https://github.com/thu-coai/KdConv/archive/master.zip"
|
61 |
+
|
62 |
+
_DOMAINS = ["travel", "music", "film"]
|
63 |
+
_DATA_TYPES = ["dialogues", "knowledge_base"]
|
64 |
+
|
65 |
+
|
66 |
+
class KdConv(datasets.GeneratorBasedBuilder):
|
67 |
+
VERSION = datasets.Version("1.1.0")
|
68 |
+
BUILDER_CONFIGS = [
|
69 |
+
datasets.BuilderConfig(
|
70 |
+
name=domain + "_" + type,
|
71 |
+
description="This part of dataset covers {0} domain and {1} data " "of the corpus".format(domain, type),
|
72 |
+
)
|
73 |
+
for domain in _DOMAINS
|
74 |
+
for type in _DATA_TYPES
|
75 |
+
] + [
|
76 |
+
datasets.BuilderConfig(
|
77 |
+
name="all_" + type,
|
78 |
+
description="This part of dataset covers all domains and {0} data of " "the corpus".format(type),
|
79 |
+
)
|
80 |
+
for type in _DATA_TYPES
|
81 |
+
]
|
82 |
+
|
83 |
+
DEFAULT_CONFIG_NAME = "all_dialogues"
|
84 |
+
|
85 |
+
def _info(self):
|
86 |
+
if "dialogues" in self.config.name:
|
87 |
+
features = datasets.Features(
|
88 |
+
{
|
89 |
+
"messages": datasets.Sequence(
|
90 |
+
{
|
91 |
+
"message": datasets.Value("string"),
|
92 |
+
"attrs": datasets.Sequence(
|
93 |
+
{
|
94 |
+
"attrname": datasets.Value("string"),
|
95 |
+
"attrvalue": datasets.Value("string"),
|
96 |
+
"name": datasets.Value("string"),
|
97 |
+
}
|
98 |
+
),
|
99 |
+
}
|
100 |
+
),
|
101 |
+
"name": datasets.Value("string"),
|
102 |
+
"domain": datasets.Value("string"),
|
103 |
+
}
|
104 |
+
)
|
105 |
+
else:
|
106 |
+
features = datasets.Features(
|
107 |
+
{
|
108 |
+
"head_entity": datasets.Value("string"),
|
109 |
+
"kb_triplets": datasets.Sequence(datasets.Sequence(datasets.Value("string"))),
|
110 |
+
"domain": datasets.Value("string"),
|
111 |
+
}
|
112 |
+
)
|
113 |
+
return datasets.DatasetInfo(
|
114 |
+
description=_DESCRIPTION,
|
115 |
+
features=features,
|
116 |
+
supervised_keys=None,
|
117 |
+
homepage=_HOMEPAGE,
|
118 |
+
license=_LICENSE,
|
119 |
+
citation=_CITATION,
|
120 |
+
)
|
121 |
+
|
122 |
+
def _split_generators(self, dl_manager):
|
123 |
+
"""Returns SplitGenerators."""
|
124 |
+
|
125 |
+
data_dir = dl_manager.download_and_extract(_URL)
|
126 |
+
base_dir = os.path.join(os.path.join(data_dir, "KdConv-master"), "data")
|
127 |
+
if "dialogues" in self.config.name:
|
128 |
+
return [
|
129 |
+
datasets.SplitGenerator(
|
130 |
+
name=datasets.Split.TRAIN,
|
131 |
+
gen_kwargs={
|
132 |
+
"data_dir": base_dir,
|
133 |
+
"split": "train",
|
134 |
+
},
|
135 |
+
),
|
136 |
+
datasets.SplitGenerator(
|
137 |
+
name=datasets.Split.TEST,
|
138 |
+
gen_kwargs={"data_dir": base_dir, "split": "test"},
|
139 |
+
),
|
140 |
+
datasets.SplitGenerator(
|
141 |
+
name=datasets.Split.VALIDATION,
|
142 |
+
gen_kwargs={
|
143 |
+
"data_dir": base_dir,
|
144 |
+
"split": "dev",
|
145 |
+
},
|
146 |
+
),
|
147 |
+
]
|
148 |
+
else:
|
149 |
+
return [
|
150 |
+
datasets.SplitGenerator(
|
151 |
+
name=datasets.Split.TRAIN,
|
152 |
+
gen_kwargs={
|
153 |
+
"data_dir": base_dir,
|
154 |
+
"split": "train",
|
155 |
+
},
|
156 |
+
),
|
157 |
+
]
|
158 |
+
|
159 |
+
def _generate_examples(self, data_dir, split):
|
160 |
+
""" Yields examples. """
|
161 |
+
if "dialogues" in self.config.name:
|
162 |
+
if "all" in self.config.name:
|
163 |
+
file_dict = {
|
164 |
+
domain: os.path.join(os.path.join(data_dir, domain), split + ".json") for domain in _DOMAINS
|
165 |
+
}
|
166 |
+
else:
|
167 |
+
domain = self.config.name.split("_")[0]
|
168 |
+
file_dict = {domain: os.path.join(os.path.join(data_dir, domain), split + ".json")}
|
169 |
+
id_ = -1
|
170 |
+
for domain, filepath in file_dict.items():
|
171 |
+
with open(filepath, encoding="utf-8") as f:
|
172 |
+
conversations = json.load(f)
|
173 |
+
for conversation in conversations:
|
174 |
+
id_ += 1
|
175 |
+
conversation["domain"] = domain
|
176 |
+
for turn in conversation["messages"]:
|
177 |
+
if "attrs" in turn:
|
178 |
+
attrnames = [kb_triplet.get("attrname", "") for kb_triplet in turn["attrs"]]
|
179 |
+
attrvalues = [kb_triplet.get("attrvalue", "") for kb_triplet in turn["attrs"]]
|
180 |
+
names = [kb_triplet.get("name", "") for kb_triplet in turn["attrs"]]
|
181 |
+
else:
|
182 |
+
attrnames, attrvalues, names = [], [], []
|
183 |
+
turn["attrs"] = {"attrname": attrnames, "attrvalue": attrvalues, "name": names}
|
184 |
+
|
185 |
+
yield id_, conversation
|
186 |
+
else:
|
187 |
+
if "all" in self.config.name:
|
188 |
+
file_dict = {
|
189 |
+
domain: os.path.join(os.path.join(data_dir, domain), "kb_" + domain + ".json")
|
190 |
+
for domain in _DOMAINS
|
191 |
+
}
|
192 |
+
else:
|
193 |
+
domain = self.config.name.split("_")[0]
|
194 |
+
file_dict = {domain: os.path.join(os.path.join(data_dir, domain), "kb_" + domain + ".json")}
|
195 |
+
|
196 |
+
id_ = -1
|
197 |
+
for domain, filepath in file_dict.items():
|
198 |
+
with open(filepath, encoding="utf-8") as f:
|
199 |
+
kb_dict = json.load(f)
|
200 |
+
for head_entity, kb_triplets in kb_dict.items():
|
201 |
+
id_ += 1
|
202 |
+
yield id_, {"head_entity": head_entity, "kb_triplets": kb_triplets, "domain": domain}
|