Coldog2333 commited on
Commit
bad741f
1 Parent(s): bbb68b1

Upload 2 files

Browse files
Files changed (2) hide show
  1. dialseg711.py +107 -0
  2. test.json +0 -0
dialseg711.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """Topic-aware multi-turn dialogue modeling"""
16
+
17
+
18
+ import json
19
+
20
+ import datasets
21
+
22
+
23
+ _CITATION = """\
24
+ @article{xu2020topic,
25
+ title={Topic-aware multi-turn dialogue modeling},
26
+ author={Xu, Yi and Zhao, Hai and Zhang, Zhuosheng},
27
+ journal={arXiv preprint arXiv:2009.12539},
28
+ year={2020}
29
+ }
30
+ """
31
+
32
+ _DESCRIPTION = """\
33
+ """
34
+
35
+
36
+ _HOMEPAGE = "https://github.com/xyease/TADAM"
37
+
38
+ _LICENSE = """\
39
+ """
40
+ # TODO: Add link to the official dataset URLs here
41
+ # The HuggingFace dataset library don't host the datasets but only point to the original files
42
+ # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
43
+ _URLs = {
44
+ "test": "https://huggingface.co/datasets/Coldog2333/dialseg711/resolve/main/test.json",
45
+ }
46
+
47
+
48
+ class Dialseg711Config(datasets.BuilderConfig):
49
+ """BuilderConfig for Dialseg711"""
50
+
51
+ def __init__(self, **kwargs):
52
+ """
53
+ Args:
54
+ **kwargs: keyword arguments forwarded to super.
55
+ """
56
+ super().__init__(version=datasets.Version("1.0.0", ""), **kwargs)
57
+ self.dataset_name = "dialseg711"
58
+
59
+
60
+ class Dialseg711(datasets.GeneratorBasedBuilder):
61
+ """Topic-aware multi-turn dialogue modeling"""
62
+
63
+ VERSION = datasets.Version("1.0.0")
64
+
65
+ def _info(self):
66
+ return datasets.DatasetInfo(
67
+ description=_DESCRIPTION,
68
+ features=datasets.Features(
69
+ {
70
+ "dial_id": datasets.Value("string"),
71
+ "utterance": datasets.features.Sequence(datasets.Value("string")),
72
+ "segmentation_label": datasets.features.Sequence(datasets.Value("int32")),
73
+ "da": datasets.features.Sequence(datasets.Value("string")),
74
+ "role": datasets.features.Sequence(datasets.Value("string")),
75
+ "turn_id": datasets.features.Sequence(datasets.Value("int32")),
76
+ "topic_id": datasets.features.Sequence(datasets.Value("int32"))
77
+ }
78
+ ),
79
+ supervised_keys=None,
80
+ homepage=_HOMEPAGE,
81
+ license=_LICENSE,
82
+ citation=_CITATION,
83
+ )
84
+
85
+ def _split_generators(self, dl_manager):
86
+ """Returns SplitGenerators."""
87
+ downloaded_files = dl_manager.download_and_extract(_URLs)
88
+ return [
89
+ datasets.SplitGenerator(
90
+ name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}
91
+ )
92
+ ]
93
+
94
+ def _generate_examples(self, filepath):
95
+ """Yields examples."""
96
+ with open(filepath, encoding="utf-8") as f:
97
+ data = json.load(f)["dial_data"][self.dataset_name]
98
+ for id_, row in enumerate(data):
99
+ yield id_, {
100
+ "dial_id": row["dial_id"],
101
+ "utterance": [turn["utterance"] for turn in row["turns"]],
102
+ "segmentation_label": [turn["segmentation_label"] for turn in row["turns"]],
103
+ "da": [turn["da"] for turn in row["turns"]],
104
+ "role": [turn["role"] for turn in row["turns"]],
105
+ "turn_id": [turn["turn_id"] for turn in row["turns"]],
106
+ "topic_id": [turn["topic_id"] for turn in row["turns"]]
107
+ }
test.json ADDED
The diff for this file is too large to render. See raw diff