| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| """ Wino-X is a parallel dataset of German, French, and Russian Winograd schemas, aligned with their English |
| counterparts, used to examine whether neural machine translation models can perform coreference resolution that |
| requires commonsense knowledge, and whether multilingual language models are capable of commonsense reasoning across |
| multiple languages. """ |
|
|
| import csv |
| import json |
| import os |
|
|
| import datasets |
|
|
| _CITATION = """\ |
| @inproceedings{Emelin2021WinoXMW, |
| title={Wino-X: Multilingual Winograd Schemas for Commonsense Reasoning and Coreference Resolution}, |
| author={Denis Emelin and Rico Sennrich}, |
| booktitle={EMNLP}, |
| year={2021} |
| } |
| """ |
|
|
| |
| _DESCRIPTION = """\ |
| Wino-X is a parallel dataset of German, French, and Russian Winograd schemas, aligned with their English |
| counterparts, used to examine whether neural machine translation models can perform coreference resolution that |
| requires commonsense knowledge and whether multilingual language models are capable of commonsense reasoning across |
| multiple languages. |
| """ |
|
|
| _HOMEPAGE = "https://github.com/demelin/Wino-X" |
|
|
| _LICENSE = "MIT" |
|
|
| |
| |
| _URLS = { |
| "mt_en_de": "https://huggingface.co/datasets/demelin/wino_x/resolve/main/data/mt/en_de_test.jsonl", |
| "mt_en_fr": "https://huggingface.co/datasets/demelin/wino_x/resolve/main/data/mt/en_fr_test.jsonl", |
| "mt_en_ru": "https://huggingface.co/datasets/demelin/wino_x/resolve/main/data/mt/en_ru_test.jsonl", |
| "lm_en_de": "https://huggingface.co/datasets/demelin/wino_x/resolve/main/data/lm/en_de_test.jsonl", |
| "lm_en_fr": "https://huggingface.co/datasets/demelin/wino_x/resolve/main/data/lm/en_fr_test.jsonl", |
| "lm_en_ru": "https://huggingface.co/datasets/demelin/wino_x/resolve/main/data/lm/en_ru_test.jsonl" |
| } |
|
|
|
|
| class WinoX(datasets.GeneratorBasedBuilder): |
| """ Wino-X is a dataset of German, French, and Russian Winograd schemas, aligned with their English counterparts """ |
|
|
| VERSION = datasets.Version("1.1.0") |
| BUILDER_CONFIGS = [ |
| datasets.BuilderConfig(name="mt_en_de", version=VERSION, |
| description="This is the EN-DE part of the Wino-X translation data."), |
| datasets.BuilderConfig(name="mt_en_fr", version=VERSION, |
| description="This is the EN-FR part of the Wino-X translation data."), |
| datasets.BuilderConfig(name="mt_en_ru", version=VERSION, |
| description="This is the EN-RU part of the Wino-X translation data."), |
| datasets.BuilderConfig(name="lm_en_de", version=VERSION, |
| description="This is the EN-DE part of the Wino-X language modeling data."), |
| datasets.BuilderConfig(name="lm_en_fr", version=VERSION, |
| description="This is the EN-FR part of the Wino-X language modeling data."), |
| datasets.BuilderConfig(name="lm_en_ru", version=VERSION, |
| description="This is the EN-RU part of the Wino-X language modeling data."), |
| ] |
|
|
| def _info(self): |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| tgt_lang = self.config.name.split('_')[-1] |
| if self.config.name.startswith('mt_'): |
| features = datasets.Features( |
| { |
| "qID": datasets.Value("string"), |
| "sentence": datasets.Value("string"), |
| "translation1": datasets.Value("string"), |
| "translation2": datasets.Value("string"), |
| "answer": datasets.Value("int64"), |
| "pronoun1": datasets.Value("string"), |
| "pronoun2": datasets.Value("string"), |
| "referent1_en": datasets.Value("string"), |
| "referent2_en": datasets.Value("string"), |
| "true_translation_referent_of_pronoun1_{}".format(tgt_lang): datasets.Value("string"), |
| "true_translation_referent_of_pronoun2_{}".format(tgt_lang): datasets.Value("string"), |
| "false_translation_referent_of_pronoun1_{}".format(tgt_lang): datasets.Value("string"), |
| "false_translation_referent_of_pronoun2_{}".format(tgt_lang): datasets.Value("string") |
| } |
| ) |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| else: |
| features = datasets.Features( |
| { |
| "qID": datasets.Value("string"), |
| "sentence": datasets.Value("string"), |
| "context_en": datasets.Value("string"), |
| "context_{}".format(tgt_lang): datasets.Value("string"), |
| "answer": datasets.Value("int64"), |
| "option1_en": datasets.Value("string"), |
| "option2_en": datasets.Value("string"), |
| "option1_{}".format(tgt_lang): datasets.Value("string"), |
| "option2_{}".format(tgt_lang): datasets.Value("string"), |
| "context_referent_of_option1_{}".format(tgt_lang): datasets.Value("string"), |
| "context_referent_of_option2_{}".format(tgt_lang): datasets.Value("string") |
| } |
| ) |
|
|
| return datasets.DatasetInfo( |
| |
| description=_DESCRIPTION, |
| |
| features=features, |
| |
| homepage=_HOMEPAGE, |
| |
| license=_LICENSE, |
| |
| citation=_CITATION, |
| ) |
|
|
| def _split_generators(self, dl_manager): |
| downloaded_files = dl_manager.download_and_extract(_URLS[self.config.name]) |
| return [datasets.SplitGenerator(name=datasets.Split.TEST, |
| gen_kwargs={'filepath': downloaded_files, 'split': 'test'})] |
|
|
| |
| def _generate_examples(self, filepath, split): |
| |
| with open(filepath, encoding="utf-8") as f: |
| for key, row in enumerate(f): |
| data = json.loads(row) |
| yield key, data |
|
|