Chuboy commited on
Commit
7e6a38f
1 Parent(s): a422aa3

Delete loading script

Browse files
Files changed (1) hide show
  1. daily_dialog.py +0 -122
daily_dialog.py DELETED
@@ -1,122 +0,0 @@
1
- # coding=utf-8
2
- # Copyright 2020 The HuggingFace Datasets Authors
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
- """DailyDialog: A Manually Labelled Multi-turn Dialogue Dataset"""
16
-
17
-
18
- import os
19
- from zipfile import ZipFile
20
-
21
- import datasets
22
-
23
-
24
- _CITATION = """\
25
- @InProceedings{li2017dailydialog,
26
- author = {Li, Yanran and Su, Hui and Shen, Xiaoyu and Li, Wenjie and Cao, Ziqiang and Niu, Shuzi},
27
- title = {DailyDialog: A Manually Labelled Multi-turn Dialogue Dataset},
28
- booktitle = {Proceedings of The 8th International Joint Conference on Natural Language Processing (IJCNLP 2017)},
29
- year = {2017}
30
- }
31
- """
32
-
33
- _DESCRIPTION = """\
34
- We develop a high-quality multi-turn dialog dataset, DailyDialog, which is intriguing in several aspects.
35
- The language is human-written and less noisy. The dialogues in the dataset reflect our daily communication way
36
- and cover various topics about our daily life. We also manually label the developed dataset with communication
37
- intention and emotion information. Then, we evaluate existing approaches on DailyDialog dataset and hope it
38
- benefit the research field of dialog systems.
39
- """
40
-
41
- _URL = "http://yanran.li/files/ijcnlp_dailydialog.zip"
42
-
43
- act_label = {
44
- "0": "__dummy__", # Added to be compatible out-of-the-box with datasets.ClassLabel
45
- "1": "inform",
46
- "2": "question",
47
- "3": "directive",
48
- "4": "commissive",
49
- }
50
-
51
- emotion_label = {
52
- "0": "no emotion",
53
- "1": "anger",
54
- "2": "disgust",
55
- "3": "fear",
56
- "4": "happiness",
57
- "5": "sadness",
58
- "6": "surprise",
59
- }
60
-
61
-
62
- class DailyDialog(datasets.GeneratorBasedBuilder):
63
- """DailyDialog: A Manually Labelled Multi-turn Dialogue Dataset"""
64
-
65
- VERSION = datasets.Version("1.0.0")
66
-
67
- __EOU__ = "__eou__"
68
-
69
- def _info(self):
70
- return datasets.DatasetInfo(
71
- description=_DESCRIPTION,
72
- features=datasets.Features(
73
- {
74
- "dialog": datasets.features.Sequence(datasets.Value("string")),
75
- "act": datasets.features.Sequence(datasets.ClassLabel(names=list(act_label.values()))),
76
- "emotion": datasets.features.Sequence(datasets.ClassLabel(names=list(emotion_label.values()))),
77
- }
78
- ),
79
- supervised_keys=None,
80
- homepage="http://yanran.li/dailydialog",
81
- citation=_CITATION,
82
- )
83
-
84
- def _split_generators(self, dl_manager: datasets.DownloadManager):
85
- dl_dir = dl_manager.download_and_extract(_URL)
86
- data_dir = os.path.join(dl_dir, "ijcnlp_dailydialog")
87
- splits = [datasets.Split.TRAIN, datasets.Split.VALIDATION, datasets.Split.TEST]
88
- return [
89
- datasets.SplitGenerator(
90
- name=split,
91
- gen_kwargs={
92
- "data_zip": os.path.join(data_dir, f"{split}.zip"),
93
- "dialog_path": f"{split}/dialogues_{split}.txt",
94
- "act_path": f"{split}/dialogues_act_{split}.txt",
95
- "emotion_path": f"{split}/dialogues_emotion_{split}.txt",
96
- },
97
- )
98
- for split in splits
99
- ]
100
-
101
- def _generate_examples(self, data_zip, dialog_path, act_path, emotion_path):
102
- with open(data_zip, "rb") as data_file:
103
- with ZipFile(data_file) as zip_file:
104
- with zip_file.open(dialog_path) as dialog_file, zip_file.open(act_path) as act_file, zip_file.open(
105
- emotion_path
106
- ) as emotion_file:
107
- for idx, (dialog_line, act_line, emotion_line) in enumerate(
108
- zip(dialog_file, act_file, emotion_file)
109
- ):
110
- if not dialog_line.strip():
111
- break
112
- dialog = dialog_line.decode().split(self.__EOU__)[:-1]
113
- act = act_line.decode().split(" ")[:-1]
114
- emotion = emotion_line.decode().split(" ")[:-1]
115
- assert (
116
- len(dialog) == len(act) == len(emotion)
117
- ), "Different turns btw dialogue & emotion & action"
118
- yield idx, {
119
- "dialog": dialog,
120
- "act": [act_label[x] for x in act],
121
- "emotion": [emotion_label[x] for x in emotion],
122
- }