fiyinoye's picture
Create dataset.py
0d5982c verified
import datasets
_CITATION = """\
@misc{yoruba2025numericalqa,
title = {Yorùbá Numerical and Logical Reasoning QA Dataset},
author = {Fiyinfoluwa Oyesanmi and Peter Olukanmi},
year = {2025},
url = {https://huggingface.co/datasets/fiyinoye/yoruba-arithmetic-dataset},
note = {A dataset for evaluating reasoning and numeral understanding in Yorùbá.}
}
"""
_DESCRIPTION = """\
This dataset contains three subsets of question-answer pairs written in Yorùbá:
(1) Arithmetic reasoning, (2) Calendar/time reasoning, and (3) Traditional numeral interpretation.
It is intended for evaluating LLMs' reasoning in low-resource, indigenous languages.
"""
_HOMEPAGE = "https://huggingface.co/datasets/fiyinoye/yoruba-arithmetic-dataset"
_LICENSE = "CC-BY-4.0"
_URLS = {
"arithmetic": "https://huggingface.co/datasets/fiyinoye/yoruba-arithmetic-dataset/blob/main/data/arithmetic.json",
"calendar": "https://huggingface.co/datasets/fiyinoye/yoruba-arithmetic-dataset/blob/main/data/calendar.json",
"numerals": "https://huggingface.co/datasets/fiyinoye/yoruba-arithmetic-dataset/blob/main/data/numerals.json",
}
class YorubaNumericalReasoning(datasets.GeneratorBasedBuilder):
VERSION = datasets.Version("1.0.0")
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features({
"id": datasets.Value("string"),
"subset": datasets.ClassLabel(names=["arithmetic", "calendar", "numerals"]),
"question": datasets.Value("string")
}),
supervised_keys=None,
homepage=_HOMEPAGE,
citation=_CITATION,
license=_LICENSE,
)
def _split_generators(self, dl_manager):
downloaded = dl_manager.download_and_extract(_URLS)
return [
datasets.SplitGenerator(
name="arithmetic", gen_kwargs={"filepath": downloaded["arithmetic"], "subset": "arithmetic"}
),
datasets.SplitGenerator(
name="calendar", gen_kwargs={"filepath": downloaded["calendar"], "subset": "calendar"}
),
datasets.SplitGenerator(
name="numerals", gen_kwargs={"filepath": downloaded["numerals"], "subset": "numerals"}
),
]
def _generate_examples(self, filepath, category):
import json
with open(filepath, encoding="utf-8") as f:
data = json.load(f)
for i, row in enumerate(data):
yield i, {
"id": row.get("id", str(i)),
"subset": subset,
"question": row["question"]
}