|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""TODO: Add a description here.""" |
|
|
|
|
|
import csv |
|
import json |
|
import os |
|
|
|
import datasets |
|
|
|
|
|
|
|
|
|
_CITATION = """\ |
|
|
|
""" |
|
|
|
|
|
|
|
_DESCRIPTION = """\ |
|
Generated dataset for testing numerical reasoning |
|
""" |
|
|
|
|
|
_HOMEPAGE = "" |
|
|
|
|
|
_LICENSE = "" |
|
|
|
|
|
|
|
|
|
_URLS = { |
|
"first_domain": "https://huggingface.co/great-new-dataset-first_domain.zip", |
|
"second_domain": "https://huggingface.co/great-new-dataset-second_domain.zip", |
|
} |
|
|
|
|
|
|
|
class NewDataset(datasets.GeneratorBasedBuilder): |
|
"""TODO: Short description of my dataset.""" |
|
|
|
VERSION = datasets.Version("0.1.0") |
|
|
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig(name="arithmetic_multiplication", version=VERSION, description="x1 x x2 = y"), |
|
datasets.BuilderConfig(name="arithmetic_addition", version=VERSION, description="x1 + x2 = y"), |
|
datasets.BuilderConfig(name="op_infer_mult", version=VERSION, description="x1 # x2 = y, must infer that # is multiplication"), |
|
datasets.BuilderConfig(name="op_infer_add", version=VERSION, description="x1 # x2 = y, must infer that # is addition"), |
|
datasets.BuilderConfig(name="time_unit_min_sec", version=VERSION, description="x minutes equals y seconds"), |
|
datasets.BuilderConfig(name="time_unit_hour_min", version=VERSION, description="x hours equals y minutes"), |
|
datasets.BuilderConfig(name="time_unit_day_hour", version=VERSION, description="x days equals y hours"), |
|
datasets.BuilderConfig(name="time_unit_week_day", version=VERSION, description="x minutes equals y seconds"), |
|
datasets.BuilderConfig(name="time_unit_month_week", version=VERSION, description="x months equals y weeks"), |
|
datasets.BuilderConfig(name="time_unit_year_month", version=VERSION, description="x years equals y months"), |
|
datasets.BuilderConfig(name="time_unit_decade_year", version=VERSION, description="x decades equals y years"), |
|
] |
|
|
|
DEFAULT_CONFIG_NAME = "first_domain" |
|
|
|
def _info(self): |
|
if ("arithmetic" in self.config.name) or ("op_infer" in self.config.name): |
|
features = datasets.Features( |
|
{ |
|
"x1": datasets.Value("int32"), |
|
"x2": datasets.Value("int32"), |
|
"y": datasets.Value("int32") |
|
} |
|
) |
|
else: |
|
features = datasets.Features( |
|
{ |
|
"x1": datasets.Value("int32"), |
|
"time_unit": datasets.Value("string"), |
|
"y": datasets.Value("int32") |
|
} |
|
) |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=features, |
|
homepage=_HOMEPAGE, |
|
license=_LICENSE, |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
|
|
gen_kwargs={ |
|
"split": "test" |
|
}, |
|
), |
|
] |
|
|
|
def _generate_examples(self, split): |
|
|
|
if ("arithmetic" in self.config.name) or ("op_infer" in self.config.name): |
|
key = 0 |
|
for x1 in range(0,100): |
|
for x2 in range(1,51): |
|
key += 1 |
|
|
|
yield key, { |
|
"x1": x1, |
|
"x2": x2, |
|
"y": x1*x2, |
|
} |
|
else: |
|
if "min_sec" in self.config.name: |
|
time_unit = "minutes" |
|
multiplier = 60 |
|
|
|
elif "hour_min" in self.config.name: |
|
time_unit = "hours" |
|
multiplier = 60 |
|
|
|
elif "day_hour" in self.config.name: |
|
time_unit = "days" |
|
multiplier = 24 |
|
|
|
elif "week_day" in self.config.name: |
|
time_unit = "weeks" |
|
multiplier = 7 |
|
|
|
elif "month_week" in self.config.name: |
|
time_unit = "months" |
|
multiplier = 30 |
|
|
|
elif "year_month" in self.config.name: |
|
time_unit = "years" |
|
multiplier = 12 |
|
|
|
elif "decade_year" in self.config.name: |
|
time_unit = "decades" |
|
multiplier = 10 |
|
|
|
for key, x1 in enumerate(range(0, 100)): |
|
yield key, { |
|
"x1": x1, |
|
"time_unit": time_unit, |
|
"y": multiplier*x1, |
|
} |
|
|