| import csv | |
| import datasets | |
| _DESCRIPTION = """\ | |
| Multilingual Simple Variations on Arithmetic Math word Problems (MSVAMP). | |
| The same 1000 problems from [MSVAMP](https://arxiv.org/pdf/2310.20246) are each translated via human annotators in Italian. | |
| You can find the input and targets in Italian and English as `.csv` files. | |
| """ | |
| _HOMEPAGE = "https://github.com/lranaldii/italian_arithmetic_reasoning" | |
| _LICENSE = "CC BY SA 4.0" | |
| _BASE_URL = "msvamp_{lang}.tsv" | |
| _LANG = ["en", "it"] | |
| class MSVAMP(datasets.GeneratorBasedBuilder): | |
| """MSVAMP""" | |
| BUILDER_CONFIGS = [ | |
| datasets.BuilderConfig( | |
| name=lang, | |
| description=f"MSVAMP {lang} set", | |
| version=datasets.Version("1.0.0"), | |
| ) | |
| for lang in _LANG | |
| ] | |
| def _info(self): | |
| features = datasets.Features( | |
| { | |
| "question": datasets.Value("string"), | |
| "answer_number": datasets.Value("int32"), | |
| } | |
| ) | |
| return datasets.DatasetInfo( | |
| description=_DESCRIPTION, | |
| features=features, | |
| homepage=_HOMEPAGE, | |
| license=_LICENSE, | |
| citation=_CITATION, | |
| ) | |
| def _split_generators(self, dl_manager): | |
| name = self.config.name | |
| filepaths = dl_manager.download_and_extract( | |
| { | |
| datasets.Split.TEST: _BASE_URL.format(lang=name), | |
| } | |
| ) | |
| return [ | |
| datasets.SplitGenerator( | |
| name=split, | |
| gen_kwargs={"filepath": path}, | |
| ) | |
| for split, path in filepaths.items() | |
| ] | |
| def _generate_examples(self, filepath): | |
| with open(filepath, encoding="utf-8") as csv_file: | |
| csv_reader = csv.reader( | |
| csv_file, | |
| delimiter=",", | |
| ) | |
| for key, row in enumerate(csv_reader): | |
| yield key, { | |
| "question": row[0], | |
| "answer_number": int(row[1]), | |
| } | |