Create dataset.py
Browse files- dataset.py +68 -0
dataset.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import datasets
|
| 2 |
+
|
| 3 |
+
_CITATION = """\
|
| 4 |
+
@misc{yoruba2025numericalqa,
|
| 5 |
+
title = {Yorùbá Numerical and Logical Reasoning QA Dataset},
|
| 6 |
+
author = {Fiyinfoluwa Oyesanmi and Peter Olukanmi},
|
| 7 |
+
year = {2025},
|
| 8 |
+
url = {https://huggingface.co/datasets/fiyinoye/yoruba-arithmetic-dataset},
|
| 9 |
+
note = {A dataset for evaluating reasoning and numeral understanding in Yorùbá.}
|
| 10 |
+
}
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
_DESCRIPTION = """\
|
| 14 |
+
This dataset contains three subsets of question-answer pairs written in Yorùbá:
|
| 15 |
+
(1) Arithmetic reasoning, (2) Calendar/time reasoning, and (3) Traditional numeral interpretation.
|
| 16 |
+
It is intended for evaluating LLMs' reasoning in low-resource, indigenous languages.
|
| 17 |
+
"""
|
| 18 |
+
|
| 19 |
+
_HOMEPAGE = "https://huggingface.co/datasets/fiyinoye/yoruba-arithmetic-dataset"
|
| 20 |
+
_LICENSE = "CC-BY-4.0"
|
| 21 |
+
|
| 22 |
+
_URLS = {
|
| 23 |
+
"arithmetic": "https://huggingface.co/datasets/fiyinoye/yoruba-arithmetic-dataset/blob/main/data/arithmetic.json",
|
| 24 |
+
"calendar": "https://huggingface.co/datasets/fiyinoye/yoruba-arithmetic-dataset/blob/main/data/calendar.json",
|
| 25 |
+
"numerals": "https://huggingface.co/datasets/fiyinoye/yoruba-arithmetic-dataset/blob/main/data/numerals.json",
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
class YorubaNumericalReasoning(datasets.GeneratorBasedBuilder):
|
| 29 |
+
VERSION = datasets.Version("1.0.0")
|
| 30 |
+
|
| 31 |
+
def _info(self):
|
| 32 |
+
return datasets.DatasetInfo(
|
| 33 |
+
description=_DESCRIPTION,
|
| 34 |
+
features=datasets.Features({
|
| 35 |
+
"id": datasets.Value("string"),
|
| 36 |
+
"subset": datasets.ClassLabel(names=["arithmetic", "calendar", "numerals"]),
|
| 37 |
+
"question": datasets.Value("string")
|
| 38 |
+
}),
|
| 39 |
+
supervised_keys=None,
|
| 40 |
+
homepage=_HOMEPAGE,
|
| 41 |
+
citation=_CITATION,
|
| 42 |
+
license=_LICENSE,
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
def _split_generators(self, dl_manager):
|
| 46 |
+
downloaded = dl_manager.download_and_extract(_URLS)
|
| 47 |
+
return [
|
| 48 |
+
datasets.SplitGenerator(
|
| 49 |
+
name="arithmetic", gen_kwargs={"filepath": downloaded["arithmetic"], "subset": "arithmetic"}
|
| 50 |
+
),
|
| 51 |
+
datasets.SplitGenerator(
|
| 52 |
+
name="calendar", gen_kwargs={"filepath": downloaded["calendar"], "subset": "calendar"}
|
| 53 |
+
),
|
| 54 |
+
datasets.SplitGenerator(
|
| 55 |
+
name="numerals", gen_kwargs={"filepath": downloaded["numerals"], "subset": "numerals"}
|
| 56 |
+
),
|
| 57 |
+
]
|
| 58 |
+
|
| 59 |
+
def _generate_examples(self, filepath, category):
|
| 60 |
+
import json
|
| 61 |
+
with open(filepath, encoding="utf-8") as f:
|
| 62 |
+
data = json.load(f)
|
| 63 |
+
for i, row in enumerate(data):
|
| 64 |
+
yield i, {
|
| 65 |
+
"id": row.get("id", str(i)),
|
| 66 |
+
"subset": subset,
|
| 67 |
+
"question": row["question"]
|
| 68 |
+
}
|