|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""TODO: Add a description here.""" |
|
|
|
|
|
import csv |
|
import json |
|
import os |
|
|
|
import datasets |
|
|
|
|
|
|
|
|
|
_CITATION = """\ |
|
@inproceedings{feng-etal-2022-emowoz, |
|
title = "{E}mo{WOZ}: A Large-Scale Corpus and Labelling Scheme for Emotion Recognition in Task-Oriented Dialogue Systems", |
|
author = "Feng, Shutong and |
|
Lubis, Nurul and |
|
Geishauser, Christian and |
|
Lin, Hsien-chin and |
|
Heck, Michael and |
|
van Niekerk, Carel and |
|
Gasic, Milica", |
|
booktitle = "Proceedings of the Thirteenth Language Resources and Evaluation Conference", |
|
month = jun, |
|
year = "2022", |
|
address = "Marseille, France", |
|
publisher = "European Language Resources Association", |
|
url = "https://aclanthology.org/2022.lrec-1.436", |
|
pages = "4096--4113", |
|
abstract = "The ability to recognise emotions lends a conversational artificial intelligence a human touch. While emotions in chit-chat dialogues have received substantial attention, emotions in task-oriented dialogues remain largely unaddressed. This is despite emotions and dialogue success having equally important roles in a natural system. Existing emotion-annotated task-oriented corpora are limited in size, label richness, and public availability, creating a bottleneck for downstream tasks. To lay a foundation for studies on emotions in task-oriented dialogues, we introduce EmoWOZ, a large-scale manually emotion-annotated corpus of task-oriented dialogues. EmoWOZ is based on MultiWOZ, a multi-domain task-oriented dialogue dataset. It contains more than 11K dialogues with more than 83K emotion annotations of user utterances. In addition to Wizard-of-Oz dialogues from MultiWOZ, we collect human-machine dialogues within the same set of domains to sufficiently cover the space of various emotions that can happen during the lifetime of a data-driven dialogue system. To the best of our knowledge, this is the first large-scale open-source corpus of its kind. We propose a novel emotion labelling scheme, which is tailored to task-oriented dialogues. We report a set of experimental results to show the usability of this corpus for emotion recognition and state tracking in task-oriented dialogues.", |
|
} |
|
""" |
|
|
|
|
|
|
|
_DESCRIPTION = """\ |
|
EmoWOZ is a user emotion recognition in task-oriented dialogues dataset, \ |
|
consisting all dialogues from MultiWOZ and 1000 additional human-machine \ |
|
dialogues (DialMAGE). Each user utterance is annotated with one of the \ |
|
following emotions: 0: neutral, 1: fearful, 2: dissatisfied, 3: apologetic, \ |
|
4: abusive, 5: excited, 6: satisfied. System utterances are annotated with \ |
|
-1. For detailed label design and explanation, please refer to the paper and \ |
|
dataset homepage. |
|
""" |
|
|
|
|
|
_HOMEPAGE = "https://zenodo.org/record/6506504" |
|
|
|
|
|
_LICENSE = "https://creativecommons.org/licenses/by-nc/4.0/legalcode" |
|
|
|
|
|
|
|
|
|
_URLS = { |
|
"emowoz_multiwoz": "https://zenodo.org/record/6506504/files/emowoz-multiwoz.json", |
|
"emowoz_dialmage": "https://zenodo.org/record/6506504/files/emowoz-dialmage.json", |
|
"emowoz_split": "https://zenodo.org/record/6506504/files/data-split.json" |
|
} |
|
|
|
|
|
|
|
class EmoWOZ(datasets.GeneratorBasedBuilder): |
|
"""EmoWOZ: A Large-Scale Corpus and Labelling Scheme for Emotion Recognition in Task-Oriented Dialogue Systems""" |
|
|
|
VERSION = datasets.Version("1.0.0") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig(name="train-all", version=VERSION, description="This part contains the training set of all user-emotion-annotated dialogues from EmoWOZ"), |
|
datasets.BuilderConfig(name="dev-all", version=VERSION, description="This part contains the development set of all user-emotion-annotated dialogues from EmoWOZ"), |
|
datasets.BuilderConfig(name="test-all", version=VERSION, description="This part contains the test set of all user-emotion-annotated dialogues from EmoWOZ"), |
|
datasets.BuilderConfig(name="train-multiwoz", version=VERSION, description="This part contains the training set of user-emotion-annotated dialogues from MultiWOZ"), |
|
datasets.BuilderConfig(name="dev-multiwoz", version=VERSION, description="This part contains the development set of user-emotion-annotated dialogues from MultiWOZ"), |
|
datasets.BuilderConfig(name="test-multiwoz", version=VERSION, description="This part contains the test set of user-emotion-annotated dialogues from MultiWOZ"), |
|
datasets.BuilderConfig(name="train-dialmage", version=VERSION, description="This part contains the training set of user-emotion-annotated dialogues from human-machine interaction (DialMAGE)"), |
|
datasets.BuilderConfig(name="dev-dialmage", version=VERSION, description="This part contains the development set of user-emotion-annotated dialogues from human-machine interaction (DialMAGE)"), |
|
datasets.BuilderConfig(name="test-dialmage", version=VERSION, description="This part contains the test set of user-emotion-annotated dialogues from human-machine interaction (DialMAGE)"), |
|
] |
|
|
|
|
|
|
|
def _info(self): |
|
|
|
|
|
features = datasets.Features( |
|
{ |
|
"dialogue_id": datasets.Value("string"), |
|
"log": datasets.features.Sequence( |
|
{ |
|
"text": datasets.Value("string"), |
|
"emotion": datasets.ClassLabel(names=[-1,0,1,2,3,4,5,6]) |
|
} |
|
) |
|
} |
|
) |
|
|
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=features, |
|
homepage=_HOMEPAGE, |
|
license=_LICENSE, |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
|
|
|
|
|
|
|
|
|
|
|
|
data_dir = dl_manager.download_and_extract(_URLS) |
|
|
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
|
|
gen_kwargs={ |
|
"multiwoz_filepath": data_dir['emowoz_multiwoz'], |
|
"dialmage_filepath": data_dir['emowoz_dialmage'], |
|
"split_filepath": data_dir['emowoz_split'], |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.VALIDATION, |
|
|
|
gen_kwargs={ |
|
"multiwoz_filepath": data_dir['emowoz_multiwoz'], |
|
"dialmage_filepath": data_dir['emowoz_dialmage'], |
|
"split_filepath": data_dir['emowoz_split'], |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
|
|
gen_kwargs={ |
|
"multiwoz_filepath": data_dir['emowoz_multiwoz'], |
|
"dialmage_filepath": data_dir['emowoz_dialmage'], |
|
"split_filepath": data_dir['emowoz_split'], |
|
}, |
|
), |
|
] |
|
|
|
|
|
def _generate_examples(self, multiwoz_filepath, dialmage_filepath, split_filepath): |
|
|
|
|
|
with open(multiwoz_filepath, encoding="utf-8") as f: |
|
multiwoz_dialogues = json.load(f) |
|
with open(dialmage_filepath, encoding="utf-8") as f: |
|
dialmage_dialogues = json.load(f) |
|
dialogues = {**multiwoz_dialogues, **dialmage_dialogues} |
|
|
|
with open(split_filepath, encoding="utf-8") as f: |
|
data_split = json.load(f) |
|
|
|
split, subset = self.config.name.split('-') |
|
if subset == 'all': |
|
dial_ids = data_split[split]['multiwoz'] + data_split[split]['dialmage'] |
|
else: |
|
dial_ids = data_split[split][subset] |
|
|
|
for key in dial_ids: |
|
yield key, { |
|
"dialogue_id": key, |
|
"log": { |
|
"text": [log['text'] for log in dialogues[key]['log']], |
|
"emotion": [a['emotion'][3]["emotion"] if i%2 == 0 else -1 for i, a in enumerate(dialogues[key]['log'])] |
|
} |
|
} |
|
|