Datasets:
Commit
·
de988d8
1
Parent(s):
5638297
Update emowoz.py
Browse filesCleaning up comments.
emowoz.py
CHANGED
|
@@ -11,19 +11,13 @@
|
|
| 11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
# See the License for the specific language governing permissions and
|
| 13 |
# limitations under the License.
|
| 14 |
-
# TODO: Address all TODOs and remove all explanatory comments
|
| 15 |
-
"""TODO: Add a description here."""
|
| 16 |
|
| 17 |
|
| 18 |
-
import csv
|
| 19 |
import json
|
| 20 |
-
import os
|
| 21 |
|
| 22 |
import datasets
|
| 23 |
|
| 24 |
|
| 25 |
-
# TODO: Add BibTeX citation
|
| 26 |
-
# Find for instance the citation on arxiv or on the dataset repo/website
|
| 27 |
_CITATION = """\
|
| 28 |
@inproceedings{feng-etal-2022-emowoz,
|
| 29 |
title = "{E}mo{WOZ}: A Large-Scale Corpus and Labelling Scheme for Emotion Recognition in Task-Oriented Dialogue Systems",
|
|
@@ -41,12 +35,23 @@ _CITATION = """\
|
|
| 41 |
publisher = "European Language Resources Association",
|
| 42 |
url = "https://aclanthology.org/2022.lrec-1.436",
|
| 43 |
pages = "4096--4113",
|
| 44 |
-
abstract = "The ability to recognise emotions lends a conversational artificial intelligence a human
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
}
|
| 46 |
"""
|
| 47 |
|
| 48 |
-
# TODO: Add description of the dataset here
|
| 49 |
-
# You can copy an official description
|
| 50 |
_DESCRIPTION = """\
|
| 51 |
EmoWOZ is a user emotion recognition in task-oriented dialogues dataset, \
|
| 52 |
consisting all dialogues from MultiWOZ and 1000 additional human-machine \
|
|
@@ -57,15 +62,10 @@ following emotions: 0: neutral, 1: fearful, 2: dissatisfied, 3: apologetic, \
|
|
| 57 |
dataset homepage.
|
| 58 |
"""
|
| 59 |
|
| 60 |
-
# TODO: Add a link to an official homepage for the dataset here
|
| 61 |
_HOMEPAGE = "https://zenodo.org/record/6506504"
|
| 62 |
|
| 63 |
-
# TODO: Add the licence for the dataset here if you can find it
|
| 64 |
_LICENSE = "https://creativecommons.org/licenses/by-nc/4.0/legalcode"
|
| 65 |
|
| 66 |
-
# TODO: Add link to the official dataset URLs here
|
| 67 |
-
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
| 68 |
-
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
| 69 |
_URLS = {
|
| 70 |
"emowoz_multiwoz": "https://zenodo.org/record/6506504/files/emowoz-multiwoz.json",
|
| 71 |
"emowoz_dialmage": "https://zenodo.org/record/6506504/files/emowoz-dialmage.json",
|
|
@@ -73,34 +73,22 @@ _URLS = {
|
|
| 73 |
}
|
| 74 |
|
| 75 |
|
| 76 |
-
|
| 77 |
class EmoWOZ(datasets.GeneratorBasedBuilder):
|
| 78 |
"""EmoWOZ: A Large-Scale Corpus and Labelling Scheme for Emotion Recognition in Task-Oriented Dialogue Systems"""
|
| 79 |
|
| 80 |
VERSION = datasets.Version("1.0.0")
|
| 81 |
|
| 82 |
-
# This is an example of a dataset with multiple configurations.
|
| 83 |
-
# If you don't want/need to define several sub-sets in your dataset,
|
| 84 |
-
# just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
|
| 85 |
-
|
| 86 |
-
# If you need to make complex sub-parts in the datasets with configurable options
|
| 87 |
-
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
|
| 88 |
-
# BUILDER_CONFIG_CLASS = MyBuilderConfig
|
| 89 |
-
|
| 90 |
-
# You will be able to load one or the other configurations in the following list with
|
| 91 |
-
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
| 92 |
-
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
| 93 |
BUILDER_CONFIGS = [
|
| 94 |
datasets.BuilderConfig(name="emowoz", version=VERSION, description="This part contains all user-emotion-annotated dialogues from EmoWOZ"),
|
| 95 |
datasets.BuilderConfig(name="multiwoz", version=VERSION, description="This part contains all user-emotion-annotated dialogues from MultiWOZ"),
|
| 96 |
datasets.BuilderConfig(name="dialmage", version=VERSION, description="This part contains all user-emotion-annotated dialogues from human-machine interactions (DialMAGE)"),
|
| 97 |
]
|
| 98 |
|
| 99 |
-
|
| 100 |
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
features = datasets.Features(
|
| 105 |
{
|
| 106 |
"dialogue_id": datasets.Value("string"),
|
|
@@ -121,19 +109,14 @@ class EmoWOZ(datasets.GeneratorBasedBuilder):
|
|
| 121 |
citation=_CITATION,
|
| 122 |
)
|
| 123 |
|
|
|
|
| 124 |
def _split_generators(self, dl_manager):
|
| 125 |
-
|
| 126 |
-
# If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
|
| 127 |
-
|
| 128 |
-
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
|
| 129 |
-
# It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
|
| 130 |
-
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
| 131 |
data_dir = dl_manager.download_and_extract(_URLS)
|
| 132 |
|
| 133 |
return [
|
| 134 |
datasets.SplitGenerator(
|
| 135 |
name=datasets.Split.TRAIN,
|
| 136 |
-
# These kwargs will be passed to _generate_examples
|
| 137 |
gen_kwargs={
|
| 138 |
"multiwoz_filepath": data_dir['emowoz_multiwoz'],
|
| 139 |
"dialmage_filepath": data_dir['emowoz_dialmage'],
|
|
@@ -143,7 +126,6 @@ class EmoWOZ(datasets.GeneratorBasedBuilder):
|
|
| 143 |
),
|
| 144 |
datasets.SplitGenerator(
|
| 145 |
name=datasets.Split.VALIDATION,
|
| 146 |
-
# These kwargs will be passed to _generate_examples
|
| 147 |
gen_kwargs={
|
| 148 |
"multiwoz_filepath": data_dir['emowoz_multiwoz'],
|
| 149 |
"dialmage_filepath": data_dir['emowoz_dialmage'],
|
|
@@ -153,7 +135,6 @@ class EmoWOZ(datasets.GeneratorBasedBuilder):
|
|
| 153 |
),
|
| 154 |
datasets.SplitGenerator(
|
| 155 |
name=datasets.Split.TEST,
|
| 156 |
-
# These kwargs will be passed to _generate_examples
|
| 157 |
gen_kwargs={
|
| 158 |
"multiwoz_filepath": data_dir['emowoz_multiwoz'],
|
| 159 |
"dialmage_filepath": data_dir['emowoz_dialmage'],
|
|
@@ -163,10 +144,9 @@ class EmoWOZ(datasets.GeneratorBasedBuilder):
|
|
| 163 |
)
|
| 164 |
]
|
| 165 |
|
| 166 |
-
|
| 167 |
def _generate_examples(self, multiwoz_filepath, dialmage_filepath, split_filepath, split):
|
| 168 |
-
|
| 169 |
-
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
| 170 |
with open(multiwoz_filepath, encoding="utf-8") as f:
|
| 171 |
multiwoz_dialogues = json.load(f)
|
| 172 |
with open(dialmage_filepath, encoding="utf-8") as f:
|
|
|
|
| 11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
# See the License for the specific language governing permissions and
|
| 13 |
# limitations under the License.
|
|
|
|
|
|
|
| 14 |
|
| 15 |
|
|
|
|
| 16 |
import json
|
|
|
|
| 17 |
|
| 18 |
import datasets
|
| 19 |
|
| 20 |
|
|
|
|
|
|
|
| 21 |
_CITATION = """\
|
| 22 |
@inproceedings{feng-etal-2022-emowoz,
|
| 23 |
title = "{E}mo{WOZ}: A Large-Scale Corpus and Labelling Scheme for Emotion Recognition in Task-Oriented Dialogue Systems",
|
|
|
|
| 35 |
publisher = "European Language Resources Association",
|
| 36 |
url = "https://aclanthology.org/2022.lrec-1.436",
|
| 37 |
pages = "4096--4113",
|
| 38 |
+
abstract = "The ability to recognise emotions lends a conversational artificial intelligence a human \
|
| 39 |
+
touch. While emotions in chit-chat dialogues have received substantial attention, emotions in \
|
| 40 |
+
task-oriented dialogues remain largely unaddressed. This is despite emotions and dialogue success \
|
| 41 |
+
having equally important roles in a natural system. Existing emotion-annotated task-oriented corpora \
|
| 42 |
+
are limited in size, label richness, and public availability, creating a bottleneck for downstream \
|
| 43 |
+
tasks. To lay a foundation for studies on emotions in task-oriented dialogues, we introduce EmoWOZ, a \
|
| 44 |
+
large-scale manually emotion-annotated corpus of task-oriented dialogues. EmoWOZ is based on MultiWOZ, \
|
| 45 |
+
a multi-domain task-oriented dialogue dataset. It contains more than 11K dialogues with more than 83K \
|
| 46 |
+
emotion annotations of user utterances. In addition to Wizard-of-Oz dialogues from MultiWOZ, we collect \
|
| 47 |
+
human-machine dialogues within the same set of domains to sufficiently cover the space of various emotions \
|
| 48 |
+
that can happen during the lifetime of a data-driven dialogue system. To the best of our knowledge, this \
|
| 49 |
+
is the first large-scale open-source corpus of its kind. We propose a novel emotion labelling scheme, \
|
| 50 |
+
which is tailored to task-oriented dialogues. We report a set of experimental results to show the usability \
|
| 51 |
+
of this corpus for emotion recognition and state tracking in task-oriented dialogues.",
|
| 52 |
}
|
| 53 |
"""
|
| 54 |
|
|
|
|
|
|
|
| 55 |
_DESCRIPTION = """\
|
| 56 |
EmoWOZ is a user emotion recognition in task-oriented dialogues dataset, \
|
| 57 |
consisting all dialogues from MultiWOZ and 1000 additional human-machine \
|
|
|
|
| 62 |
dataset homepage.
|
| 63 |
"""
|
| 64 |
|
|
|
|
| 65 |
_HOMEPAGE = "https://zenodo.org/record/6506504"
|
| 66 |
|
|
|
|
| 67 |
_LICENSE = "https://creativecommons.org/licenses/by-nc/4.0/legalcode"
|
| 68 |
|
|
|
|
|
|
|
|
|
|
| 69 |
_URLS = {
|
| 70 |
"emowoz_multiwoz": "https://zenodo.org/record/6506504/files/emowoz-multiwoz.json",
|
| 71 |
"emowoz_dialmage": "https://zenodo.org/record/6506504/files/emowoz-dialmage.json",
|
|
|
|
| 73 |
}
|
| 74 |
|
| 75 |
|
|
|
|
| 76 |
class EmoWOZ(datasets.GeneratorBasedBuilder):
|
| 77 |
"""EmoWOZ: A Large-Scale Corpus and Labelling Scheme for Emotion Recognition in Task-Oriented Dialogue Systems"""
|
| 78 |
|
| 79 |
VERSION = datasets.Version("1.0.0")
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
BUILDER_CONFIGS = [
|
| 82 |
datasets.BuilderConfig(name="emowoz", version=VERSION, description="This part contains all user-emotion-annotated dialogues from EmoWOZ"),
|
| 83 |
datasets.BuilderConfig(name="multiwoz", version=VERSION, description="This part contains all user-emotion-annotated dialogues from MultiWOZ"),
|
| 84 |
datasets.BuilderConfig(name="dialmage", version=VERSION, description="This part contains all user-emotion-annotated dialogues from human-machine interactions (DialMAGE)"),
|
| 85 |
]
|
| 86 |
|
| 87 |
+
DEFAULT_CONFIG_NAME = "emowoz"
|
| 88 |
|
| 89 |
+
|
| 90 |
+
def _info(self):
|
| 91 |
+
|
| 92 |
features = datasets.Features(
|
| 93 |
{
|
| 94 |
"dialogue_id": datasets.Value("string"),
|
|
|
|
| 109 |
citation=_CITATION,
|
| 110 |
)
|
| 111 |
|
| 112 |
+
|
| 113 |
def _split_generators(self, dl_manager):
|
| 114 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
data_dir = dl_manager.download_and_extract(_URLS)
|
| 116 |
|
| 117 |
return [
|
| 118 |
datasets.SplitGenerator(
|
| 119 |
name=datasets.Split.TRAIN,
|
|
|
|
| 120 |
gen_kwargs={
|
| 121 |
"multiwoz_filepath": data_dir['emowoz_multiwoz'],
|
| 122 |
"dialmage_filepath": data_dir['emowoz_dialmage'],
|
|
|
|
| 126 |
),
|
| 127 |
datasets.SplitGenerator(
|
| 128 |
name=datasets.Split.VALIDATION,
|
|
|
|
| 129 |
gen_kwargs={
|
| 130 |
"multiwoz_filepath": data_dir['emowoz_multiwoz'],
|
| 131 |
"dialmage_filepath": data_dir['emowoz_dialmage'],
|
|
|
|
| 135 |
),
|
| 136 |
datasets.SplitGenerator(
|
| 137 |
name=datasets.Split.TEST,
|
|
|
|
| 138 |
gen_kwargs={
|
| 139 |
"multiwoz_filepath": data_dir['emowoz_multiwoz'],
|
| 140 |
"dialmage_filepath": data_dir['emowoz_dialmage'],
|
|
|
|
| 144 |
)
|
| 145 |
]
|
| 146 |
|
| 147 |
+
|
| 148 |
def _generate_examples(self, multiwoz_filepath, dialmage_filepath, split_filepath, split):
|
| 149 |
+
|
|
|
|
| 150 |
with open(multiwoz_filepath, encoding="utf-8") as f:
|
| 151 |
multiwoz_dialogues = json.load(f)
|
| 152 |
with open(dialmage_filepath, encoding="utf-8") as f:
|