Datasets:
File size: 10,622 Bytes
1cfbdd1 |
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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# coding=utf-8
"""Leyzer"""
import json
import datasets
import pandas as pd
_DESCRIPTION = """\
Leyzer is a multilingual text corpus designed to study multilingual and cross-lingual natural language
understanding (NLU) models and the strategies of localization of virtual assistants. It consists of 20
domains across three languages: English, Spanish and Polish, with 186 intents and a wide range of
samples, ranging from 1 to 672 sentences per intent.
"""
_CITATION = """\
@inproceedings{sowanski2020leyzer,
title={Leyzer: A Dataset for Multilingual Virtual Assistants},
author={Sowa{\'n}ski, Marcin and Janicki, Artur},
booktitle={International Conference on Text, Speech, and Dialogue},
pages={477--486},
year={2020},
organization={Springer}
}
"""
_LICENSE = """\
"""
_URL = "https://github.com/cartesinus/leyzer/raw/0.2.0/corpora/0.2.0/leyzer-0.2.0-fedcsis.tar.gz"
_LANGUAGES = ['en-US', 'es-ES', 'pl-PL']
_DOMAINS = ['Airconditioner', 'Calendar', 'Console', 'Contacts', 'Email', 'Facebook', 'Fitbit',
'Gdrive', 'Instagram', 'News', 'Phone', 'Slack', 'Speaker', 'Spotify', 'Translate',
'Twitter', 'Weather', 'Websearch', 'Wikipedia', 'Yelp', 'Youtube']
_INTENTS = ["AddAlbumToPlaylist", "AddEventOnDateWithName", "AddEventWithName",
"AddSongToPlaylist", "AddSongToPlaylistWithName", "AddSongWithNameToPlaylistWithName",
"AddWeight", "CallContact", "CallEmergency", "CallNumber", "ChangeLanguageToLanguage",
"ChangeTemperature", "CheckCalendarEventName", "CheckCalendarOnDate", "CheckChannelHistory",
"CheckLastMessages", "CheckMessagesFromUser", "CheckMessagesInChannel",
"CheckUserStatus", "ConsoleCD", "ConsoleCP", "ConsoleEdit", "ConsoleLS",
"ConsoleMV", "ConsoleRM", "CreateContactWithNameAndWithNumberAndWithType",
"CreateFile", "CreateFileWithName", "CreatePlaylist", "CreatePlaylistWithName",
"DecreaseVolume", "DecreaseVolumeByPercent", "DetectLanguage", "DownloadAsPdf",
"EditContactWithName", "EditContactWithNumber", "EditNumberInContactWithName",
"EditNumberInContactWithNameToNumberAndToType", "FindChannelWithQuery",
"FindQuery", "FindQueryOnChannel", "FollowUser", "GetHumidity", "GetTemperature",
"GetTemperatureFromDevice", "GoToElementNumber", "IncreaseVolume",
"IncreaseVolumeByPercent", "MoonphaseInLocation", "MoonphaseInLocationOnDate",
"MuteOff", "MuteOn", "NextSong", "NextVideo", "NotifyOnEventInLocation",
"NotifyOnEventStart", "NotifyOnNewFromFollowing", "NotifyOnWeight", "NotifyWhenEventNameStart",
"NotifyWhenPortalUpdates", "NotifyWhenPortalUpdatesInSection", "NotNotifyOnEventInLocation",
"NotNotifyOnEventStart", "OpenCalendar", "OpenContacts", "OpenEmail", "OpenEngine",
"OpenFacebook", "OpenFileWithName", "OpenGdrive", "OpenInstagram", "OpenMyContact",
"OpenRestaurants", "OpenRestaurantsInLocation", "OpenSlack", "OpenSpotify",
"OpenTwitter", "OpenWeather", "OpenWikipedia", "OpenYT", "Pause",
"PlayAlbumOfTypeByArtist", "PlayPlaylist", "PlaySong", "PlaySongByArtist",
"PostPicture", "PostPictureWithCaption", "PostPictureWithUrl",
"PostPictureWithUrlAndWithCaption", "PostStatus", "PostWithLastPictureWithLocationAndWithHashtag",
"PostWithPicturesFromDateAndWithLocation", "PreviousSong", "RandomPage",
"RepeatOnOff", "ReplyToEmailFromAddress", "ScrollDown", "ScrollUp",
"SearchByCategory", "SearchByCategoryInLocation", "SearchByQuery",
"SearchByQueryInLocation", "SearchByRating", "SearchByRatingInLocation",
"SearchByReviewCount", "SearchByReviewCountInLocation", "SearchImagesOnEngine",
"SearchImagesWithTextOnEngine", "SearchImagesWithTextOnEngineWithWidthAndWithHeight",
"SearchImagesWithTextOnEngineWithWidthAndWithHeightAndWithCondition", "SearchInLocation", "SearchQuery",
"SearchRestaurant", "SearchText", "SearchTextOnEngine", "SeekByTime", "SendEmail",
"SendEmailToAddress", "SendEmailToAddressWithSubject", "SendEmailToAddressWithSubjectAndWithMessage",
"SendMessageToChannel", "SendMessageToUser", "SendPictureToChannel", "SendPictureToChannelWithCaption",
"SendPictureWithUrlToChannel", "SendSlackMessage", "SendTwitterMessage", "SetDefaultLanguage",
"SetDefaultLanguageToLanguage", "SetPurposeOnChannel", "SetStatusAway", "SetTemperatureBetweenValues",
"SetTemperatureOnDevice", "SetTemperatureToValue", "SetTemperatureToValueOnDevice", "SetTopicInChannel",
"ShareFileWithNameToAddress", "ShowAlbumWithName", "ShowBMI", "ShowChannelWithCategory",
"ShowChannelWithName", "ShowContactWithEmail", "ShowContactWithName", "ShowContactWithNumber",
"ShowContactWithNumberAndWithEmail", "ShowDanceability", "ShowEmailFromSender", "ShowEmailFromTime",
"ShowEmailWithLabel", "ShowEmailWithPriority", "ShowEmailWithSubject", "ShowFilesFromTime",
"ShowFilesWithSize", "ShowFilesWithStar", "ShowFilesWithType", "ShowLastNumberPictures",
"ShowNewestFiles", "ShowNews", "ShowNewsFromSection", "ShowOldestFiles", "ShowPictures",
"ShowPicturesFromDate", "ShowPicturesWithFilter", "ShowPicturesWithHashtag",
"ShowPicturesWithLocation", "ShowSMS", "ShowSteps", "ShowStepsOnDate", "ShowSubscribedChannels",
"ShowTwittsWithHashtag", "ShuffleOnOff", "SMSToContact", "SMSToContactWithMessage",
"SortAlphabetical", "SortReverseAlphabetical", "SunriseAndSunsetInLocation",
"SunriseAndSunsetInLocationAndOnDate", "SunriseInLocation", "SunsetInLocation",
"TakePicture", "TranslateText", "TranslateTextFromLanguage", "TranslateTextFromLanguageToLanguage",
"TranslateTextFromLanguageToLanguageWithEngine", "TranslateTextToLanguage",
"TranslateToLanguage", "TurnOff", "TurnOn", "TurnOnOrOff", "UnfollowUser",
"WeatherInLocation", "WeatherTomorrow", "WeatherTomorrowInLocation",
"NotifyOnNewOnChannel"
]
_LEVELS = ['L0TC', 'L1TC', 'L2TC', 'REPHRASE']
_VPS = ['verb_pattern_01', 'verb_pattern_02', 'verb_pattern_03', 'verb_pattern_04',
'verb_pattern_05', 'verb_pattern_06', 'verb_pattern_07', 'verb_pattern_08',
'verb_pattern_09', 'verb_pattern_10', 'verb_pattern_11', 'verb_pattern_12', 'verb_pattern_13']
class LeyzerConfig(datasets.BuilderConfig):
"""BuilderConfig for Leyzer."""
def __init__(self, dataset_version=None, *args, **kwargs):
"""BuilderConfig for Leyzer.
Args:
**kwargs: keyword arguments forwarded to super.
"""
super(LeyzerConfig, self).__init__(*args, **kwargs)
self.dataset_version = dataset_version if dataset_version else "1.0"
self.data_url = _URL
class Leyzer(datasets.GeneratorBasedBuilder):
"""Leyzer"""
# All individual locale datasets are served from the latest version.
BUILDER_CONFIGS = [
LeyzerConfig(
name = name,
dataset_version = '0.2.0',
version = datasets.Version("0.2.0"),
description = f"The Leyzer v0.2.0 corpora for {name}",
) for name in _LANGUAGES
]
# Version 1.0
BUILDER_CONFIGS.append(LeyzerConfig(
name = "all",
dataset_version = '0.2.0',
version = datasets.Version("0.2.0"),
description = f"The Leyzer v0.2.0 corpora for entire corpus",
)
)
DEFAULT_CONFIG_NAME = "all"
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features(
{
"id": datasets.Value("string"),
"locale": datasets.Value("string"),
"partition": datasets.Value("string"),
"domain": datasets.features.ClassLabel(names=_DOMAINS),
"intent": datasets.features.ClassLabel(names=_INTENTS),
"utterance": datasets.Value("string"),
"bio": datasets.Value("string"),
},
),
supervised_keys=None,
homepage="https://github.com/cartesinus/leyzer/",
citation=_CITATION,
license=_LICENSE,
)
def _split_generators(self, dl_manager):
archive = dl_manager.download(self.config.data_url)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={
"files": dl_manager.iter_archive(archive),
"split": "train",
"lang": self.config.name,
}
),
datasets.SplitGenerator(
name=datasets.Split.VALIDATION,
gen_kwargs={
"files": dl_manager.iter_archive(archive),
"split": "valid",
"lang": self.config.name,
}
),
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={
"files": dl_manager.iter_archive(archive),
"split": "test",
"lang": self.config.name,
}
),
]
def _generate_examples(self, files, split, lang):
key_ = 0
if lang == "all":
lang = _LANGUAGES.copy()
else:
lang = [lang]
for path, f in files:
l = path.split("/")[-1].split(".")[0]
if not lang:
break
elif l in lang:
lang.remove(l)
else:
continue
# Read the file
lines = f.read().decode(encoding="utf-8").split("\n")
for line in lines:
if not line:
continue
data = json.loads(line)
if data["partition"] != split:
continue
yield key_, {
"id": data["id"],
"locale": data["locale"],
"partition": data["partition"],
"domain": data["domain"],
"intent": data["intent"],
"utterance": data["utterance"],
"bio": data["bio"],
}
key_ += 1
|