|
import os |
|
import datasets |
|
import pandas as pd |
|
|
|
_CITATION = """\ |
|
""" |
|
|
|
|
|
_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. |
|
""" |
|
_ABSABank_imm_DESCRIPTION = """\ |
|
Absabank-Imm (where ABSA stands for "Aspect-Based Sentiment Analysis" and Imm for "Immigration") is a subset of the Swedish ABSAbank, created to be a part of the SuperLim collection. In Absabank-Imm, texts and paragraphs are manually labelled according to the sentiment (on 1--5 scale) that the author expresses towards immigration in Sweden (this task is known as aspect-based sentiment analysis or stance analysis). To create Absabank-Imm, the original Absabank has been substantially reformatted, but no changes to the annotation were made. The dataset contains 4872 short texts. |
|
""" |
|
_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 = """\ |
|
""" |
|
_SweDN_DESCRIPTION = """\ |
|
AbstractThe SWE-DN corpus is based on 1,963,576 news articles from the Swedish newspaper Dagens Nyheter (DN) during the years 2000--2020. The articles are filtered to resemble the CNN/DailyMail dataset both regarding textual structure""" |
|
_SweDiag_CITATION = """\ |
|
""" |
|
_SweFaq_DESCRIPTION = """\ |
|
Vanliga frågor från svenska myndigheters webbsidor med svar i randomiserad ordning""" |
|
_SweFaq_CITATION = """\ |
|
""" |
|
_SweNLI_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.""" |
|
|
|
_SweWinogender_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.""" |
|
|
|
_SweWinograd_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.""" |
|
|
|
_argumentation_sentences_DESCRIPTION = """\ |
|
Argumentation sentences is a translated corpus for the task of identifying stance in relation to a topic. It consists of sentences labeled with pro, con or non in relation to one of six topics. |
|
The original dataset can be found here https://github.com/trtm/AURC. The test set is manually corrected translations, the training set is machine translated. """ |
|
|
|
_argumentation_sentences_DESCRIPTION_CITATION = """\ |
|
""" |
|
|
|
_RELEASE_VERSION = "2.0.1" |
|
_GH_REPOSITORY = "https://raw.githubusercontent.com/spraakbanken/SuperLim-2/" |
|
_URL = f"{_GH_REPOSITORY}/{_RELEASE_VERSION}/" |
|
|
|
_TASKS = { |
|
"absabank-imm": "absabank-imm", |
|
"argumentation_sent":"argumentation-sentences", |
|
"dalaj-ged": "dalaj-ged-superlim", |
|
"sweana": "sweanalogy", |
|
"swediagnostics": "swediagnostics", |
|
"swedn": "swedn", |
|
"swefaq": "swefaq", |
|
"swenli": "swenli", |
|
"swepar": "sweparaphrase", |
|
"swesat": "swesat-synonyms", |
|
"swesim_relatedness": "supersim-superlim-relatedness", |
|
"swesim_similarity": "supersim-superlim-similarity", |
|
"swewic": "swewic", |
|
"swewinogender": "swewinogender", |
|
"swewinograd": "swewinograd" |
|
|
|
} |
|
|
|
class SuperLimConfig(datasets.BuilderConfig): |
|
"""BuilderConfig for SuperLim.""" |
|
|
|
def __init__(self, features, data_url, citation, url, label_classes=("False", "True"), **kwargs): |
|
"""BuilderConfig for SuperLim. |
|
|
|
Args: |
|
features: `list[string]`, list of the features that will appear in the |
|
feature dict. Should not include "label". |
|
data_url: `string`, url to download the zip file from. |
|
citation: `string`, citation for the data set. |
|
url: `string`, url for information about the data set. |
|
label_classes: `list[string]`, the list of classes for the label if the |
|
label is present as a string. Non-string labels will be cast to either |
|
'False' or 'True'. |
|
**kwargs: keyword arguments forwarded to super. |
|
""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
super(SuperLimConfig, self).__init__(version=datasets.Version("2.0.0"), **kwargs) |
|
self.features = features |
|
self.label_classes = label_classes |
|
self.data_url = data_url |
|
self.citation = citation |
|
self.url = url |
|
|
|
class SuperLim(datasets.GeneratorBasedBuilder): |
|
"""The SuperLim benchmark.""" |
|
|
|
VERSION = datasets.Version("2.0.0") |
|
|
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig(name="absabank-imm", version=VERSION, description=_ABSABank_imm_DESCRIPTION), |
|
datasets.BuilderConfig(name="argumentation_sent", version=VERSION, description=_argumentation_sentences_DESCRIPTION), |
|
datasets.BuilderConfig(name="dalaj-ged", version=VERSION, description=_DaLAJ_DESCRIPTION), |
|
datasets.BuilderConfig(name="sweana", version=VERSION, description=_SweAna_DESCRIPTION), |
|
datasets.BuilderConfig(name="swediagnostics", version=VERSION, description=_SweDiag_DESCRIPTION), |
|
datasets.BuilderConfig(name="swedn", version=VERSION, description=_SweDN_DESCRIPTION), |
|
datasets.BuilderConfig(name="swefaq", version=VERSION, description=_SweFaq_DESCRIPTION), |
|
datasets.BuilderConfig(name="swenli", version=VERSION, description=_SweNLI_DESCRIPTION), |
|
datasets.BuilderConfig(name="swepar", version=VERSION, description=_SwePar_DESCRIPTION), |
|
datasets.BuilderConfig(name="swesat", version=VERSION, description=_SweSat_DESCRIPTION), |
|
datasets.BuilderConfig(name="swesim_relatedness", version=VERSION, description=_SweSim_DESCRIPTION), |
|
datasets.BuilderConfig(name="swesim_similarity", version=VERSION, description=_SweSim_DESCRIPTION), |
|
datasets.BuilderConfig(name="swewic", version=VERSION, description=_SweWic_DESCRIPTION), |
|
datasets.BuilderConfig(name="swewinogender", version=VERSION, description=_SweWinogender_DESCRIPTION), |
|
datasets.BuilderConfig(name="swewinograd", version=VERSION, description=_SweWinograd_DESCRIPTION) |
|
] |
|
|
|
def _info(self): |
|
|
|
if self.config.name == 'absabank-imm': |
|
features = datasets.Features({ |
|
"id": datasets.Value("string"), |
|
"text": datasets.Value("string"), |
|
"label": datasets.Value(dtype='float32') |
|
}) |
|
elif self.config.name == 'argumentation_sent': |
|
features = datasets.Features({ |
|
"sentence_id": datasets.Value("string"), |
|
"topic": datasets.Value("string"), |
|
"label": datasets.ClassLabel(num_classes=3, names=['pro', 'con', 'non']), |
|
"sentence": datasets.Value("string") |
|
}) |
|
elif self.config.name == "dalaj-ged": |
|
features = datasets.Features({ |
|
"sentence": datasets.Value("string"), |
|
"label": datasets.ClassLabel(num_classes=2, names=['correct', 'incorrect']), |
|
"meta": datasets.Features({ |
|
'error_span': datasets.Features({ |
|
'start': datasets.Value(dtype='int64'), |
|
'stop': datasets.Value(dtype='int64') |
|
}), |
|
'confusion_pair': datasets.Features({ |
|
'incorrect_span': datasets.Value("string"), |
|
'correction': datasets.Value('string') |
|
}), |
|
'error_label': datasets.Value("string"), |
|
'education_level': datasets.Value("string"), |
|
'l1': datasets.Value("string"), |
|
'data_source': datasets.Value("string") |
|
}) |
|
}) |
|
elif self.config.name == "sweana": |
|
features = datasets.Features({ |
|
"pair1_element1": datasets.Value("string"), |
|
"pair1_element2": datasets.Value("string"), |
|
"pair2_element1": datasets.Value("string"), |
|
"pair2_element2": datasets.Value("string"), |
|
"category": datasets.Value("string"), |
|
}) |
|
elif self.config.name == 'swediagnostics': |
|
features = datasets.Features({ |
|
'premise': datasets.Value("string"), |
|
'hypothesis': datasets.Value("string"), |
|
'label': datasets.ClassLabel(num_classes=3, names=['entailment', 'contradiction', 'neutral']), |
|
'meta': datasets.Features({ |
|
'lexical_semantics': datasets.Value("string"), |
|
'predicate_argument_structure': datasets.Value("string"), |
|
'logic': datasets.Value("string"), |
|
'knowledge': datasets.Value("string"), |
|
'domain': datasets.Value("string") |
|
}) |
|
}) |
|
elif self.config.name == 'swedn': |
|
features = datasets.Features({ |
|
"id": datasets.Value("string"), |
|
"headline": datasets.Value("string"), |
|
"summary": datasets.Value("string"), |
|
"article": datasets.Value("string"), |
|
"article_category": datasets.Value("string") |
|
}) |
|
elif self.config.name == "swefaq": |
|
features = datasets.Features({ |
|
"category_id": datasets.Value("string"), |
|
"candidate_answers": datasets.Sequence(datasets.Value("string")), |
|
"question": datasets.Value("string"), |
|
"label": datasets.Value(dtype='int32'), |
|
"meta": datasets.Features({ |
|
"category": datasets.Value("string"), |
|
"source": datasets.Value("string"), |
|
"link": datasets.Value("string"), |
|
}) |
|
}) |
|
elif self.config.name == 'swenli': |
|
features = datasets.Features({ |
|
"id": datasets.Value("string"), |
|
"premise": datasets.Value("string"), |
|
"hypothesis": datasets.Value("string"), |
|
"label": datasets.ClassLabel(num_classes=3, names=['entailment', 'contradiction', 'neutral']) |
|
}) |
|
elif self.config.name == "swepar": |
|
features = datasets.Features({ |
|
"genre": datasets.Value("string"), |
|
"file": datasets.Value("string"), |
|
"sentence_1": datasets.Value("string"), |
|
"sentence_2": datasets.Value("string"), |
|
"label": datasets.Value(dtype='float32'), |
|
}) |
|
elif self.config.name == "swesat": |
|
features = datasets.Features({ |
|
"id": datasets.Value("string"), |
|
"item": datasets.Value("string"), |
|
"candidate_answers": datasets.Sequence( |
|
datasets.Value("string"), |
|
length=5 |
|
), |
|
"label": datasets.ClassLabel(5), |
|
"meta": datasets.Features({ |
|
"comment": datasets.Value("string") |
|
}) |
|
}) |
|
elif self.config.name == "swesim_relatedness": |
|
features = datasets.Features({ |
|
"word_1": datasets.Value("string"), |
|
"word_2": datasets.Value("string"), |
|
"label": datasets.Value(dtype='float32') |
|
}) |
|
elif self.config.name == "swesim_similarity": |
|
features = datasets.Features({ |
|
"word_1": datasets.Value("string"), |
|
"word_2": datasets.Value("string"), |
|
"label": datasets.Value(dtype='float32') |
|
}) |
|
elif self.config.name == "swewic": |
|
features = datasets.Features({ |
|
"idx": datasets.Value(dtype='int32'), |
|
"first": datasets.Features({ |
|
"context": datasets.Value("string"), |
|
"word": datasets.Features({ |
|
"location": datasets.Features({ |
|
"start": datasets.Value(dtype='int32'), |
|
"stop": datasets.Value(dtype='int32') |
|
}), |
|
"text": datasets.Value("string") |
|
}) |
|
}), |
|
"second": datasets.Features({ |
|
"context": datasets.Value("string"), |
|
"word": datasets.Features({ |
|
"location": datasets.Features({ |
|
"start": datasets.Value(dtype='int32'), |
|
"stop": datasets.Value(dtype='int32') |
|
}), |
|
"text": datasets.Value("string") |
|
}) |
|
}), |
|
"label": datasets.ClassLabel(num_classes=2, names=['same_sense', 'different_sense']), |
|
"meta": datasets.Features({ |
|
"first_source": datasets.Value("string"), |
|
"first_sense_id": datasets.Value("string"), |
|
"second_source": datasets.Value("string"), |
|
"second_sense_id": datasets.Value("string"), |
|
"pos": datasets.Value("string") |
|
}) |
|
}) |
|
elif self.config.name == 'swewinogender': |
|
features = datasets.Features({ |
|
"idx": datasets.Value(dtype='int32'), |
|
'premise': datasets.Value("string"), |
|
'hypothesis': datasets.Value("string"), |
|
'label': datasets.ClassLabel(num_classes=3, names=['entailment', 'contradiction', 'neutral']), |
|
'meta': datasets.Features({ |
|
'tuple_id': datasets.Value("string"), |
|
'template_id': datasets.Value("string"), |
|
'occupation_participant': datasets.Value("string"), |
|
'other_participant': datasets.Value("string"), |
|
'pronoun': datasets.Value("string") |
|
}) |
|
}) |
|
elif self.config.name == 'swewinograd': |
|
features = datasets.Features({ |
|
"idx": datasets.Value(dtype='int32'), |
|
'text': datasets.Value("string"), |
|
'label': datasets.ClassLabel(num_classes=2, names=['not_coreferring', 'coreferring']), |
|
'pronoun': datasets.Features({ |
|
'text': datasets.Value("string"), |
|
'location': datasets.Features({ |
|
"start": datasets.Value(dtype='int32'), |
|
"stop": datasets.Value(dtype='int32') |
|
}) |
|
}), |
|
'candidate_antecedent': datasets.Features({ |
|
"text": datasets.Value("string"), |
|
'location': datasets.Features({ |
|
"start": datasets.Value(dtype='int32'), |
|
"stop": datasets.Value(dtype='int32') |
|
}) |
|
}), |
|
'meta': datasets.Features({ |
|
'snippet_id': datasets.Value("string") |
|
}) |
|
}) |
|
else: |
|
raise ValueError(f"Subset {self.config.name} does not exist.") |
|
return datasets.DatasetInfo( |
|
|
|
description=_DESCRIPTION, |
|
|
|
features=features, |
|
|
|
|
|
|
|
|
|
homepage=_HOMEPAGE, |
|
|
|
license=_LICENSE, |
|
|
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
file_format = 'jsonl' |
|
splits = [] |
|
DATA_FOLDER = 'supersim-superlim' if self.config.name.startswith('swesim') else _TASKS[self.config.name] |
|
data_dir_test = dl_manager.download_and_extract(os.path.join(_URL,DATA_FOLDER,f"{_TASKS[self.config.name]}_test.{file_format}")) |
|
split_test = datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
gen_kwargs={ |
|
"filepath": data_dir_test, |
|
"split": "test" |
|
}, |
|
) |
|
splits.append(split_test) |
|
if self.config.name in ("absabank-imm", "argumentation_sent", "dalaj-ged", "swefaq", |
|
"swewic", "swenli", "swedn", "swepar", "swewinograd"): |
|
data_dir_dev = dl_manager.download_and_extract(os.path.join(_URL,DATA_FOLDER,f"{_TASKS[self.config.name]}_dev.{file_format}")) |
|
split_dev = datasets.SplitGenerator( |
|
name=datasets.Split.VALIDATION, |
|
gen_kwargs={ |
|
"filepath": data_dir_dev, |
|
"split": "dev", |
|
}, |
|
) |
|
splits.append(split_dev) |
|
if self.config.name in ("absabank-imm", "argumentation_sent", "dalaj-ged", "swefaq", |
|
"swewic", "swenli", "swedn", "swepar", "swesim_relatedness", |
|
"swesim_similarity", "swesat", "sweana", "swewinograd"): |
|
data_dir_train = dl_manager.download_and_extract(os.path.join(_URL,DATA_FOLDER,f"{_TASKS[self.config.name]}_train.{file_format}")) |
|
split_train = datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
gen_kwargs={ |
|
"filepath": data_dir_train, |
|
"split": "train", |
|
}, |
|
) |
|
splits.append(split_train) |
|
return splits |
|
|
|
def _generate_examples(self, filepath, split): |
|
|
|
|
|
df = pd.read_json(filepath, lines=True) |
|
for key, row in df.iterrows(): |
|
if self.config.name == "absabank-imm": |
|
yield key, { |
|
"id": row['id'], |
|
"text": row["text"], |
|
"label": row["label"], |
|
} |
|
elif self.config.name == "argumentation_sent": |
|
yield key, { |
|
"sentence_id": row["sentence_id"], |
|
"topic": row["topic"], |
|
"label": row["label"], |
|
"sentence" : row["sentence"], |
|
} |
|
elif self.config.name == "dalaj-ged": |
|
|
|
meta = row['meta'] |
|
|
|
if not meta['error_span'] and not meta['confusion_pair']: |
|
meta['error_span']['start'] = None |
|
meta['error_span']['stop'] = None |
|
meta['confusion_pair']['incorrect_span'] = None |
|
meta['confusion_pair']['correction'] = None |
|
yield key, { |
|
"sentence": row["sentence"], |
|
"label": row["label"], |
|
"meta": meta, |
|
} |
|
elif self.config.name == "sweana": |
|
yield key, { |
|
"pair1_element1": row["pair1_element1"], |
|
"pair1_element2": row["pair1_element2"], |
|
"pair2_element1": row["pair2_element1"], |
|
"pair2_element2": row["pair2_element2"], |
|
"category": row["category"], |
|
} |
|
elif self.config.name == "swediagnostics": |
|
yield key, { |
|
'premise': row['premise'], |
|
'hypothesis': row['hypothesis'], |
|
'label': row['label'], |
|
'meta': row['meta'], |
|
} |
|
elif self.config.name == "swedn": |
|
yield key, { |
|
'id': row['id'], |
|
'headline': row['headline'], |
|
'summary': row['summary'], |
|
'article': row['article'], |
|
'article_category': row['article_category'] |
|
} |
|
elif self.config.name == "swefaq": |
|
yield key, { |
|
"category_id": row['category_id'], |
|
"question": row["question"], |
|
"candidate_answers": row['candidate_answers'], |
|
"label": row["label"], |
|
"meta": row['meta'], |
|
} |
|
elif self.config.name == "swenli": |
|
yield key, { |
|
'id': row['id'], |
|
'premise': row['premise'], |
|
'hypothesis': row['hypothesis'], |
|
'label': row['label'] |
|
} |
|
elif self.config.name == "swepar": |
|
yield key, { |
|
"genre": row["genre"], |
|
"file": row["file"], |
|
"sentence_1": row["sentence_1"], |
|
"sentence_2": row["sentence_2"], |
|
"label": row["label"], |
|
} |
|
elif self.config.name == "swesat": |
|
yield key, { |
|
"id": row["id"], |
|
"item": row["item"], |
|
"candidate_answers": row["candidate_answers"], |
|
"label": row["label"], |
|
"meta": row["meta"], |
|
} |
|
elif self.config.name == "swesim_relatedness": |
|
yield key, { |
|
"word_1": row["word_1"], |
|
"word_2": row["word_2"], |
|
"label": row["label"], |
|
} |
|
elif self.config.name == "swesim_similarity": |
|
yield key, { |
|
"word_1": row["word_1"], |
|
"word_2": row["word_2"], |
|
"label": row["label"], |
|
} |
|
elif self.config.name == "swewic": |
|
yield key, { |
|
"idx": row["idx"], |
|
"first": row["first"], |
|
"second": row["second"], |
|
"label": row["label"], |
|
"meta": row["meta"], |
|
} |
|
elif self.config.name == "swewinogender": |
|
yield key, { |
|
"idx": row["idx"], |
|
"premise": row["premise"], |
|
"hypothesis": row["hypothesis"], |
|
"label": row["label"], |
|
"meta": row["meta"], |
|
} |
|
elif self.config.name == "swewinograd": |
|
yield key, { |
|
"idx": row["idx"], |
|
"text": row["text"], |
|
"label": row["label"], |
|
"pronoun": row["pronoun"], |
|
"candidate_antecedent": row["candidate_antecedent"], |
|
"meta": row["meta"] |
|
} |
|
else: |
|
raise ValueError(f"Subset {self.config.name} does not exist") |