olympic_test / olympic_test.py
Benjamin02's picture
Upload 15 files
8645a28 verified
raw
history blame
2.75 kB
import os
import datasets
import json
_CITATION = """\
"""
_DESCRIPTION = """\
OlympicArena
"""
_HOMEPAGE = ""
_URL = ""
subject_list = ["Math", "Physics", "Chemistry", "Biology", "Geography", "Astronomy", "CS"]
class OlympicArenaConfig(datasets.BuilderConfig):
"""BuilderConfig"""
def __init__(self, **kwargs):
"""BuilderConfig
Args:
**kwargs: keyword arguments forwarded to super.
"""
super(OlympicArenaConfig, self).__init__(**kwargs)
class OlympicArena(datasets.GeneratorBasedBuilder):
BUILDER_CONFIGS = [
OlympicArenaConfig(name=subject) for subject in subject_list
]
def _info(self):
features = datasets.Features(
{
"id": datasets.Value("string"),
"problem": datasets.Value("string"),
"prompt": datasets.Value("string"),
"figure_urls": datasets.Sequence(datasets.Value("string")),
"answer": datasets.Sequence(datasets.Value("string")),
"solution": datasets.Value("string"),
"answer_type": datasets.Value("string"),
"unit": datasets.Sequence(datasets.Value("string")),
"answer_sequence": datasets.Sequence(datasets.Value("string")),
"type_sequence": datasets.Sequence(datasets.Value("string")),
"test_cases": datasets.Sequence(
{
"input": datasets.Value("string"),
"output": datasets.Value("string")
}
),
"subject": datasets.Value("string"),
"language": datasets.Value("string"),
"modality": datasets.Value("string")
}
)
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=features,
homepage=_HOMEPAGE,
citation=_CITATION,
)
def _split_generators(self, dl_manager):
subject = self.config.name
return [
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={
"filepath": dl_manager.download(os.path.join("test", subject+".json")),
},
),
datasets.SplitGenerator(
name=datasets.Split("val"),
gen_kwargs={
"filepath": dl_manager.download(os.path.join("val", subject+".json")),
},
),
]
def _generate_examples(self, filepath):
with open(filepath, "r") as f:
data = json.load(f)
for i, instance in enumerate(data):
yield i, instance