File size: 4,334 Bytes
1f19ff2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# coding=utf-8
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""DSTC11 Dataset."""

import json
import datasets


_CITATION = """\
@misc{gung2023natcs,
      title={NatCS: Eliciting Natural Customer Support Dialogues}, 
      author={James Gung and Emily Moeng and Wesley Rose and Arshit Gupta and Yi Zhang and Saab Mansour},
      year={2023},
      eprint={2305.03007},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}
@misc{gung2023intent,
      title={Intent Induction from Conversations for Task-Oriented Dialogue Track at DSTC 11}, 
      author={James Gung and Raphael Shu and Emily Moeng and Wesley Rose and Salvatore Romeo and Yassine Benajiba and Arshit Gupta and Saab Mansour and Yi Zhang},
      year={2023},
      eprint={2304.12982},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}
"""

_DESCRIPTION = """
This repository contains data, relevant scripts and baseline code for the Dialog Systems Technology Challenge (DSTC11).
"""

_HOMEPAGE = "https://github.com/amazon-science/dstc11-track2-intent-induction"
_URLs = {
    "validation": "development/dialogues.jsonl.gz",
    "test-banking": "test-banking/dialogues.jsonl.gz",
    "test-finance": "test-finance/dialogues.jsonl.gz",
}

class Dstc11(datasets.GeneratorBasedBuilder):
    """Data from the DSTC 11 tasks."""

    VERSION = datasets.Version("1.0.0")


    BUILDER_CONFIGS = [
        datasets.BuilderConfig(
            name="data",
            version=datasets.Version("1.0.0"),
            description=_DESCRIPTION,
        ),
        datasets.BuilderConfig(name="docs", version=datasets.Version("1.0.0"), description=_DESCRIPTION),
    ]

    DEFAULT_CONFIG_NAME = "data"
    
    
    def _info(self):
        features=datasets.Features({
            "dialogue_id": datasets.Value("string"),
            "turns": datasets.Sequence(
                datasets.Features({
                    "turn_id": datasets.Value("string"),
                    "speaker_role": datasets.Value("string"),
                    "utterance": datasets.Value("string"),
                    "dialogue_acts": datasets.Sequence(
                        datasets.Value("string")
                    ),
                    "intents": datasets.Sequence(
                        datasets.Value("string")
                    ),
                })
            )
        })
        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=features,
            supervised_keys=None,
            citation=_CITATION,
            homepage=_HOMEPAGE)

    def _split_generators(self, dl_manager):
        """Returns SplitGenerators."""
        data_dir = dl_manager.download_and_extract(_URLs)
        return [
            datasets.SplitGenerator(
                name=datasets.Split.VALIDATION,
                gen_kwargs={"filepaths": [data_dir["validation"]], "split": "validation"},
            ),
            datasets.SplitGenerator(
                name=datasets.Split.TEST,
                gen_kwargs={"filepaths": [data_dir["test-banking"], data_dir["test-finance"]], "split": "test"},
            ),
            datasets.SplitGenerator(
                name="test.banking",
                gen_kwargs={"filepaths": [data_dir["test-banking"]], "split": "test.banking"},
            ),
            datasets.SplitGenerator(
                name="test.finance",
                gen_kwargs={"filepaths": [data_dir["test-finance"]], "split": "test.finance"},
            ),
        ]

    def _generate_examples(self, filepaths, split):
        key = 0
        for filepath in filepaths:
            for line in open(filepath, encoding="utf-8"):
                line = json.loads(line)
                yield key, line   
                key += 1