Graham Neubig commited on
Commit
1f19ff2
1 Parent(s): 9e63abf

Add data loading script

Browse files
Files changed (1) hide show
  1. dstc11.py +121 -0
dstc11.py ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ """DSTC11 Dataset."""
16
+
17
+ import json
18
+ import datasets
19
+
20
+
21
+ _CITATION = """\
22
+ @misc{gung2023natcs,
23
+ title={NatCS: Eliciting Natural Customer Support Dialogues},
24
+ author={James Gung and Emily Moeng and Wesley Rose and Arshit Gupta and Yi Zhang and Saab Mansour},
25
+ year={2023},
26
+ eprint={2305.03007},
27
+ archivePrefix={arXiv},
28
+ primaryClass={cs.CL}
29
+ }
30
+ @misc{gung2023intent,
31
+ title={Intent Induction from Conversations for Task-Oriented Dialogue Track at DSTC 11},
32
+ 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},
33
+ year={2023},
34
+ eprint={2304.12982},
35
+ archivePrefix={arXiv},
36
+ primaryClass={cs.CL}
37
+ }
38
+ """
39
+
40
+ _DESCRIPTION = """
41
+ This repository contains data, relevant scripts and baseline code for the Dialog Systems Technology Challenge (DSTC11).
42
+ """
43
+
44
+ _HOMEPAGE = "https://github.com/amazon-science/dstc11-track2-intent-induction"
45
+ _URLs = {
46
+ "validation": "development/dialogues.jsonl.gz",
47
+ "test-banking": "test-banking/dialogues.jsonl.gz",
48
+ "test-finance": "test-finance/dialogues.jsonl.gz",
49
+ }
50
+
51
+ class Dstc11(datasets.GeneratorBasedBuilder):
52
+ """Data from the DSTC 11 tasks."""
53
+
54
+ VERSION = datasets.Version("1.0.0")
55
+
56
+
57
+ BUILDER_CONFIGS = [
58
+ datasets.BuilderConfig(
59
+ name="data",
60
+ version=datasets.Version("1.0.0"),
61
+ description=_DESCRIPTION,
62
+ ),
63
+ datasets.BuilderConfig(name="docs", version=datasets.Version("1.0.0"), description=_DESCRIPTION),
64
+ ]
65
+
66
+ DEFAULT_CONFIG_NAME = "data"
67
+
68
+
69
+ def _info(self):
70
+ features=datasets.Features({
71
+ "dialogue_id": datasets.Value("string"),
72
+ "turns": datasets.Sequence(
73
+ datasets.Features({
74
+ "turn_id": datasets.Value("string"),
75
+ "speaker_role": datasets.Value("string"),
76
+ "utterance": datasets.Value("string"),
77
+ "dialogue_acts": datasets.Sequence(
78
+ datasets.Value("string")
79
+ ),
80
+ "intents": datasets.Sequence(
81
+ datasets.Value("string")
82
+ ),
83
+ })
84
+ )
85
+ })
86
+ return datasets.DatasetInfo(
87
+ description=_DESCRIPTION,
88
+ features=features,
89
+ supervised_keys=None,
90
+ citation=_CITATION,
91
+ homepage=_HOMEPAGE)
92
+
93
+ def _split_generators(self, dl_manager):
94
+ """Returns SplitGenerators."""
95
+ data_dir = dl_manager.download_and_extract(_URLs)
96
+ return [
97
+ datasets.SplitGenerator(
98
+ name=datasets.Split.VALIDATION,
99
+ gen_kwargs={"filepaths": [data_dir["validation"]], "split": "validation"},
100
+ ),
101
+ datasets.SplitGenerator(
102
+ name=datasets.Split.TEST,
103
+ gen_kwargs={"filepaths": [data_dir["test-banking"], data_dir["test-finance"]], "split": "test"},
104
+ ),
105
+ datasets.SplitGenerator(
106
+ name="test.banking",
107
+ gen_kwargs={"filepaths": [data_dir["test-banking"]], "split": "test.banking"},
108
+ ),
109
+ datasets.SplitGenerator(
110
+ name="test.finance",
111
+ gen_kwargs={"filepaths": [data_dir["test-finance"]], "split": "test.finance"},
112
+ ),
113
+ ]
114
+
115
+ def _generate_examples(self, filepaths, split):
116
+ key = 0
117
+ for filepath in filepaths:
118
+ for line in open(filepath, encoding="utf-8"):
119
+ line = json.loads(line)
120
+ yield key, line
121
+ key += 1