Datasets:
File size: 25,478 Bytes
b034bdf 9b4758c b034bdf 4d20ae4 b034bdf db3ac8c b034bdf ed5c809 b034bdf 12a7afa b034bdf 12a7afa b034bdf a71dc4c 6a29f52 a71dc4c b034bdf 014f148 93cb36d 014f148 6a29f52 93cb36d a71dc4c 93cb36d 6a29f52 a71dc4c ed5c809 a71dc4c b034bdf 12a7afa b034bdf 60cfc7a 7732f67 014f148 b034bdf 014f148 12a7afa b034bdf 9b4758c a1564af 6a29f52 a1564af 9b4758c 014f148 93cb36d 014f148 c2e0a45 6a29f52 93cb36d ed5c809 93cb36d a71dc4c 93cb36d a71dc4c 93cb36d a71dc4c 93cb36d a71dc4c 93cb36d a71dc4c 93cb36d a71dc4c 93cb36d a71dc4c 93cb36d a71dc4c 93cb36d a71dc4c 6a29f52 9b4758c |
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 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 |
# coding=utf-8
# Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Lint as: python3
"""The SuperGLUE benchmark."""
import json
import os
import datasets
import pandas as pd
_CITATION = """\
"""
# You can copy an official description
_DESCRIPTION = """\
"""
_HOMEPAGE = ""
_LICENSE = ""
_SUPERLIM_CITATION = """\
Yvonne Adesam, Aleksandrs Berdicevskis, Felix Morger (2020): SwedishGLUE – Towards a Swedish Test Set for Evaluating Natural Language Understanding Models BibTeX
[1] Original Absabank:
Jacobo Rouces, Lars Borin, Nina Tahmasebi (2020): Creating an Annotated Corpus for Aspect-Based Sentiment Analysis in Swedish, in Proceedings of the 5th conference in Digital Humanities in the Nordic Countries, Riga, Latvia, October 21-23, 2020. BibTeX
[2] DaLAJ:
Volodina, Elena, Yousuf Ali Mohammed, and Julia Klezl (2021). DaLAJ - a dataset for linguistic acceptability judgments for Swedish. In Proceedings of the 10th Workshop on Natural Language Processing for Computer Assisted Language Learning (NLP4CALL 2021). Linköping Electronic Conference Proceedings 177:3, s. 28-37. https://ep.liu.se/ecp/177/003/ecp2021177003.pdf
[3] Analogy:
Tosin Adewumi, Foteini Liwicki, Markus Liwicki. (2020). Corpora compared: The case of the Swedish Gigaword & Wikipedia corpora. In: Proceedings of the 8th SLTC, Gothenburg. arXiv preprint arXiv:2011.03281
[4] Swedish Test Set for SemEval 2020 Task 1:
Unsupervised Lexical Semantic Change Detection: Dominik Schlechtweg, Barbara McGillivray, Simon Hengchen, Haim Dubossarsky, Nina Tahmasebi (2020): SemEval-2020 Task 1: Unsupervised Lexical Semantic Change Detection, in Proceedings of the Fourteenth Workshop on Semantic Evaluation (SemEval2020), Barcelona, Spain (Online), December 12, 2020. BibTeX
[5] Winogender:
Saga Hansson, Konstantinos Mavromatakis, Yvonne Adesam, Gerlof Bouma and Dana Dannélls (2021). The Swedish Winogender Dataset. In The 23rd Nordic Conference on Computational Linguistics (NoDaLiDa 2021), Reykjavik.
[6] SuperSim:
Hengchen, Simon and Tahmasebi, Nina (2021). SuperSim: a test set for word similarity and relatedness in Swedish. In The 23rd Nordic Conference on Computational Linguistics (NoDaLiDa 2021), Reykjavik. arXiv preprint arXiv:2014.05228
"""
_SUPERLIM_DESCRIPTION = """\
SuperLim, A standardized suite for evaluation and analysis of Swedish natural language understanding systems.
"""
_DaLAJ_DESCRIPTION = """\
Determine whether a sentence is correct Swedish or not.
"""
_DaLAJ_CITATION = """\
[1] Original Absabank:
Jacobo Rouces, Lars Borin, Nina Tahmasebi (2020): Creating an Annotated Corpus for Aspect-Based Sentiment Analysis in Swedish, in Proceedings of the 5th conference in Digital Humanities in the Nordic Countries, Riga, Latvia, October 21-23, 2020. BibTeX
[2] DaLAJ:
Volodina, Elena, Yousuf Ali Mohammed, and Julia Klezl (2021). DaLAJ - a dataset for linguistic acceptability judgments for Swedish. In Proceedings of the 10th Workshop on Natural Language Processing for Computer Assisted Language Learning (NLP4CALL 2021). Linköping Electronic Conference Proceedings 177:3, s. 28-37. https://ep.liu.se/ecp/177/003/ecp2021177003.pdf
"""
_SweAna_DESCRIPTION = """\
The Swedish analogy test set follows the format of the original Google version. However, it is bigger and balanced across the 2 major categories,
having a total of 20,638 samples, made up of 10,381 semantic and 10,257 syntactic samples. It is also roughly balanced across the syntactic subsections.
There are 5 semantic subsections and 6 syntactic subsections. The dataset was constructed, partly using the samples in the English version,
with the help of tools dedicated to Swedish translation and it was proof-read for corrections by two native speakers (with a percentage agreement of 98.93\%)."""
_SweAna_CITATION = """\
[1] Original Absabank:
Jacobo Rouces, Lars Borin, Nina Tahmasebi (2020): Creating an Annotated Corpus for Aspect-Based Sentiment Analysis in Swedish, in Proceedings of the 5th conference in Digital Humanities in the Nordic Countries, Riga, Latvia, October 21-23, 2020. BibTeX
"""
_SweDiag_DESCRIPTION = """\
Färdig preliminär översättning av SuperGLUE diagnostik. Datan innehåller alla ursprungliga annoterade satspar från SuperGLUE tillsammans
med deras svenska översättningar."""
_SweDiag_CITATION = """\
"""
_SweFaq_DESCRIPTION = """\
Vanliga frågor från svenska myndigheters webbsidor med svar i randomiserad ordning"""
_SweFaq_CITATION = """\
"""
_SweFracas_DESCRIPTION = """\
A textual inference/entailment problem set, derived from FraCas. The original English Fracas [1] was converted to html and edited by Bill MacCartney [2],
and then automatically translated to Swedish by Peter Ljunglöf and Magdalena Siverbo [3]. The current tabular form of the set was created by Aleksandrs Berdicevskis
by merging the Swedish and English versions and removing some of the problems. Finally, Lars Borin went through all the translations, correcting and Swedifying them manually.
As a result, many translations are rather liberal and diverge noticeably from the English original."""
_SweFracas_CITATION = """\
"""
_SwePar_DESCRIPTION = """\
SweParaphrase is a subset of the automatically translated Swedish Semantic Textual Similarity dataset (Isbister and Sahlgren, 2020).
It consists of 165 manually corrected Swedish sentence pairs paired with the original English sentences and their similarity scores
ranging between 0 (no meaning overlap) and 5 (meaning equivalence). These scores were taken from the English data, they were assigned
by Crowdsourcing through Mechanical Turk. Each sentence pair belongs to one genre (e.g. news, forums or captions).
The task is to determine how similar two sentences are."""
_SwePar_CITATION = """\
"""
_SweSat_DESCRIPTION = """\
The dataset provides a gold standard for Swedish word synonymy/definition. The test items are collected from the Swedish Scholastic
Aptitude Test (högskoleprovet), currently spanning the years 2006--2021 and 822 vocabulary test items. The task for the tested system
is to determine which synonym or definition of five alternatives is correct for each test item.
"""
_SweSat_CITATION = """\
"""
_SweSim_DESCRIPTION = """\
SuperSim is a large-scale similarity and relatedness test set for Swedish built with expert human judgments. The test set is composed of 1360 word-pairs independently judged for both relatedness and similarity by five annotators."""
_SweWgr_DESCRIPTION = """\
The SweWinogender test set is diagnostic dataset to measure gender bias in coreference resolution. It is modelled after the English Winogender benchmark,
and is released with reference statistics on the distribution of men and women between occupations and the association between gender and occupation in modern corpus material."""
_SweWsc_DESCRIPTION = """\
SweWinograd is a pronoun resolution test set, containing constructed items in the style of Winograd schema’s. The interpretation of the target pronouns is determined by (common sense)
reasoning and knowledge, and not by syntactic constraints, lexical distributional information or discourse structuring patterns.
The dataset contains 90 multiple choice with multiple correct answers test items."""
_SweWic_DESCRIPTION = """\
The Swedish Word-in-Context dataset provides a benchmark for evaluating distributional models of word meaning, in particular context-sensitive/dynamic models. Constructed following the principles of the (English)
Word-in-Context dataset, SweWiC consists of 1000 sentence pairs, where each sentence in a pair contains an occurence of a potentially ambiguous focus word specific to that pair. The question posed to the tested
system is whether these two occurrences represent instances of the same word sense. There are 500 same-sense pairs and 500 different-sense pairs."""
# TODO: Add link to the official dataset URLs here
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
_URL = "https://huggingface.co/datasets/AI-Sweden/SuperLim/resolve/main/data/"
_TASKS = {
"dalaj": "DaLAJ",
"sweana": "SweAna",
"swediag": "SweDiag",
"swefaq": "SweFaq",
"swefracas": "SweFracas",
"swepar": "SwePar",
"swesat": "SweSat",
"swesim_relatedness": "SweSim_relatedness",
"swesim_similarity": "SweSim_similarity",
"swewgr": "SweWgr",
"swewic": "SweWic",
"swewsc": "SweWsc"
}
# TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
class SuperLim(datasets.GeneratorBasedBuilder):
"""TODO: Short description of my dataset."""
VERSION = datasets.Version("1.1.0")
# If you need to make complex sub-parts in the datasets with configurable options
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
# BUILDER_CONFIG_CLASS = MyBuilderConfig
# You will be able to load one or the other configurations in the following list with
# data = datasets.load_dataset('my_dataset', 'first_domain')
# data = datasets.load_dataset('my_dataset', 'second_domain')
BUILDER_CONFIGS = [
datasets.BuilderConfig(name="dalaj", version=VERSION, description=_DaLAJ_DESCRIPTION),
datasets.BuilderConfig(name="sweana", version=VERSION, description=_SweAna_DESCRIPTION),
datasets.BuilderConfig(name="swediag", version=VERSION, description=_SweDiag_DESCRIPTION),
datasets.BuilderConfig(name="swefaq", version=VERSION, description=_SweFaq_DESCRIPTION),
datasets.BuilderConfig(name="swefracas", version=VERSION, description=_SweFracas_DESCRIPTION),
datasets.BuilderConfig(name="swepar", version=VERSION, description=_SwePar_DESCRIPTION),
datasets.BuilderConfig(name="swesat", version=VERSION, description=_SweSat_DESCRIPTION),
datasets.BuilderConfig(name="swesim", version=VERSION, description=_SweSim_DESCRIPTION),
datasets.BuilderConfig(name="swewgr", version=VERSION, description=_SweWgr_DESCRIPTION),
datasets.BuilderConfig(name="swewic", version=VERSION, description=_SweWic_DESCRIPTION),
datasets.BuilderConfig(name="swewsc", version=VERSION, description=_SweWsc_DESCRIPTION),
]
def _info(self):
# TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
if self.config.name == "dalaj": # This is the name of the configuration selected in BUILDER_CONFIGS above
features = datasets.Features(
{
"original_sentence": datasets.Value("string"),
"corrected_sentence": datasets.Value("string"),
"error_indices": datasets.Value("string"),
"corrected_indices": datasets.Value("string"),
"error_corr_pair": datasets.Value("string"),
"error_label": datasets.Value("string"),
"l1": datasets.Value("string"),
"approximate_level": datasets.Value("string"),
# These are the features of your dataset like images, labels ...
}
)
elif self.config.name == "sweana":
features = datasets.Features(
{
"a": datasets.Value("string"),
"b": datasets.Value("string"),
"c": datasets.Value("string"),
"d": datasets.Value("string"),
"relation": datasets.Value("string"),
}
)
elif self.config.name == "swediag":
features = datasets.Features(
{
"premise": datasets.Value("string"),
"hypothesis": datasets.Value("string"),
"label": datasets.Value("string"),
}
)
elif self.config.name == "swefaq":
features = datasets.Features(
{
"question": datasets.Value("string"),
"candidate_answer": datasets.Value("string"),
"correct_answer": datasets.Value("string"),
}
)
elif self.config.name == "swefracas":
features = datasets.Features(
{
"answer": datasets.Value("string"),
"question": datasets.Value("string"),
"premiss_1": datasets.Value("string"),
"premiss_2": datasets.Value("string"),
"premiss_3": datasets.Value("string"),
"premiss_4": datasets.Value("string"),
"premiss_5": datasets.Value("string"),
}
)
elif self.config.name == "swepar":
features = datasets.Features(
{
"sentence_1": datasets.Value("string"),
"sentence_2": datasets.Value("string"),
"similarity_score": datasets.Value("string"),
}
)
elif self.config.name == "swesat":
features = datasets.Features(
{
"target_item": datasets.Value("string"),
"answer_1": datasets.Value("string"),
"answer_2": datasets.Value("string"),
"answer_3": datasets.Value("string"),
"answer_4": datasets.Value("string"),
"answer_5": datasets.Value("string"),
}
)
elif self.config.name == "swesim_relatedness":
features = datasets.Features(
{
"word_1": datasets.Value("string"),
"word_2": datasets.Value("string"),
"relatedness": datasets.Value("string"),
}
)
elif self.config.name == "swesim_similarity":
features = datasets.Features(
{
"word_1": datasets.Value("string"),
"word_2": datasets.Value("string"),
"similarity": datasets.Value("string"),
}
)
elif self.config.name == "swewgr":
features = datasets.Features(
{
"text": datasets.Value("string"),
"challenge": datasets.Value("string"),
"responses": datasets.Value("string"),
}
)
elif self.config.name == "swewic":
features = datasets.Features(
{
"sentence_1": datasets.Value("string"),
"word_1": datasets.Value("string"),
"sentence_2": datasets.Value("string"),
"word_2": datasets.Value("string"),
"same_sense": datasets.Value("string"),
"start_1": datasets.Value("string"),
"start_2": datasets.Value("string"),
"end_1": datasets.Value("string"),
"end_2": datasets.Value("string"),
}
)
elif self.config.name == "swewsc":
features = datasets.Features(
{
"passage": datasets.Value("string"),
"challenge_text": datasets.Value("string"),
"response_text": datasets.Value("string"),
"challenge_begin": datasets.Value("string"),
"challenge_end": datasets.Value("string"),
"response_begin": datasets.Value("string"),
"response_end": datasets.Value("string"),
"label": datasets.Value("string")
}
)
else: # This is an example to show how to have different features for "first_domain" and "second_domain"
features = datasets.Features(
{
"sentence": datasets.Value("string"),
"option2": datasets.Value("string"),
"second_domain_answer": datasets.Value("string")
# These are the features of your dataset like images, labels ...
}
)
return datasets.DatasetInfo(
# This is the description that will appear on the datasets page.
description=_DESCRIPTION,
# This defines the different columns of the dataset and their types
features=features, # Here we define them above because they are different between the two configurations
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
# supervised_keys=("sentence", "label"),
# Homepage of the dataset for documentation
homepage=_HOMEPAGE,
# License for the dataset if available
license=_LICENSE,
# Citation for the dataset
citation=_CITATION,
)
def _split_generators(self, dl_manager):
# TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
# If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
# 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.
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
#urls = _URLS[self.config.name]
if self.config.name == "dalaj":
data_dir_test = dl_manager.download_and_extract(os.path.join(_URL,_TASKS[self.config.name],"test.csv"))
data_dir_train = dl_manager.download_and_extract(os.path.join(_URL,_TASKS[self.config.name],"train.csv"))
data_dir_dev = dl_manager.download_and_extract(os.path.join(_URL,_TASKS[self.config.name],"dev.csv"))
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
# These kwargs will be passed to _generate_examples
gen_kwargs={
"filepath": data_dir_train,
"split": "train",
},
),
datasets.SplitGenerator(
name=datasets.Split.TEST,
# These kwargs will be passed to _generate_examples
gen_kwargs={
"filepath": data_dir_test,
"split": "test"
},
),
datasets.SplitGenerator(
name=datasets.Split.VALIDATION,
# These kwargs will be passed to _generate_examples
gen_kwargs={
"filepath": data_dir_dev,
"split": "dev",
},
),
]
else:
data_dir_test = dl_manager.download_and_extract(os.path.join(_URL, _TASKS[self.config.name], "test.csv"))
return [
datasets.SplitGenerator(
name=datasets.Split.TEST,
# These kwargs will be passed to _generate_examples
gen_kwargs={
"filepath": data_dir_test,
"split": "test"
},
),
]
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
def _generate_examples(self, filepath, split):
# TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
df = pd.read_csv(filepath)
for key, row in df.iterrows():
if self.config.name == "dalaj":
# Yields examples as (key, example) tuples
yield key, {
"original_sentence": row["original sentence"],
"corrected_sentence": row["corrected sentence"],
"error_indices": row["error indices"],
"corrected_indices": row["corrected indices"],
"error_corr_pair": row["error-corr pair"],
"error_label": row["error label"],
"l1": row["l1"],
"approximate_level": row["approximate level"],
}
elif self.config.name == "sweana":
yield key, {
"a": row["A"],
"b": row["B"],
"c": row["C"],
"d": row["D"],
"relation": row["relation"],
}
elif self.config.name == "swediag":
yield key, {
"premise": row["Premise_SE"],
"hypothesis": row["Hypothesis_SE"],
"label": row["Label"],
}
elif self.config.name == "swefaq":
yield key, {
"question": row["question"],
"candidate_answer": row["candidate_answer"],
"correct_answer": row["correct_answer"],
}
elif self.config.name == "swefracas":
yield key, {
"answer": row["svar"],
"question": row["fråga"],
"premiss_1": row["premiss_1"],
"premiss_2": row["premiss_2"],
"premiss_3": row["premiss_3"],
"premiss_4": row["premiss_4"],
"premiss_5": row["premiss_5"],
}
elif self.config.name == "swepar":
yield key, {
"sentence_1": row["sentence_1"],
"sentence_2": row["sentence_2"],
"similarity_score": row["similarity_score"],
}
elif self.config.name == "swesat":
yield key, {
"target_item": row["target_item"],
"answer_1": row["answer_1"],
"answer_2": row["answer_2"],
"answer_3": row["answer_3"],
"answer_4": row["answer_4"],
"answer_5": row["answer_5"],
}
elif self.config.name == "swesim_relatedness":
yield key, {
"word_1": row["Word 1"],
"word_2": row["Word 2"],
"relatedness": row["Average"],
}
elif self.config.name == "swesim_similarity":
yield key, {
"word_1": row["Word 1"],
"word_2": row["Word 2"],
"similarity": row["Average"],
}
elif self.config.name == "swewgr":
yield key, {
"text": row["text"],
"challenge": row["challenge"],
"responses": row["responses"],
}
elif self.config.name == "swewic":
yield key, {
"sentence_1": row["sentence1"],
"word_1": row["word1"],
"sentence_2": row["sentence2"],
"word_2": row["word2"],
"same_sense": row["same_sense"],
"start_1": row["start1"],
"end_1": row["end1"],
"start_2": row["start2"],
"end_2": row["end2"],
}
elif self.config.name == "swewsc":
yield key, {
"passage": row["Word 1"],
"challenge_text": row["challenge_text 2"],
"response_text": row["response_text"],
"challenge_begin":row["challenge_begin"],
"challenge_end":row["challenge_end"],
"response_begin":row["response_begin"],
"response_end":row["response_end"],
"label":row["label"]
}
else:
yield key, {
"sentence": data["sentence"],
"option2": data["option2"],
"second_domain_answer": "" if split == "test" else data["second_domain_answer"],
}
|