|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""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 NumericalReasoning(datasets.GeneratorBasedBuilder): |
|
"""TODO: Short description of my dataset.""" |
|
|
|
VERSION = datasets.Version("0.1.0") |
|
|
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig(name="multiplication", version=VERSION, description="x1 x x2 = y"), |
|
datasets.BuilderConfig(name="addition", version=VERSION, description="x1 + x2 = y"), |
|
datasets.BuilderConfig(name="convert_min_sec", version=VERSION, description="x minutes equals y seconds"), |
|
datasets.BuilderConfig(name="convert_hour_min", version=VERSION, description="x hours equals y minutes"), |
|
datasets.BuilderConfig(name="convert_day_hour", version=VERSION, description="x days equals y hours"), |
|
datasets.BuilderConfig(name="convert_week_day", version=VERSION, description="x minutes equals y seconds"), |
|
datasets.BuilderConfig(name="convert_month_week", version=VERSION, description="x months equals y weeks"), |
|
datasets.BuilderConfig(name="convert_year_month", version=VERSION, description="x years equals y months"), |
|
datasets.BuilderConfig(name="convert_decade_year", version=VERSION, description="x decades equals y years"), |
|
] |
|
|
|
DEFAULT_CONFIG_NAME = "multiplication" |
|
|
|
def _info(self): |
|
if (self.config.name == "multiplication") or (self.config.name == "addition"): |
|
features = datasets.Features( |
|
{ |
|
"x1": datasets.Value("int32"), |
|
"x2": datasets.Value("int32"), |
|
"y": datasets.Value("int32") |
|
} |
|
) |
|
else: |
|
features = datasets.Features( |
|
{ |
|
"x": datasets.Value("int32"), |
|
"x_time_unit": datasets.Value("string"), |
|
"y": datasets.Value("int32") |
|
"y_time_unit": datasets.Value("string"), |
|
} |
|
) |
|
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 self.config.name == "multiplication": |
|
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, |
|
} |
|
|
|
elif self.config.name == "addition": |
|
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: |
|
x_time_unit = "minutes" |
|
y_time_unit = "seconds" |
|
multiplier = 60 |
|
|
|
elif "hour_min" in self.config.name: |
|
x_time_unit = "hours" |
|
y_time_unit = "minutes" |
|
multiplier = 60 |
|
|
|
elif "day_hour" in self.config.name: |
|
x_time_unit = "days" |
|
y_time_unit = "hours" |
|
multiplier = 24 |
|
|
|
elif "week_day" in self.config.name: |
|
x_time_unit = "weeks" |
|
y_time_unit = "days" |
|
multiplier = 7 |
|
|
|
elif "month_week" in self.config.name: |
|
x_time_unit = "months" |
|
y_time_unit = "weeks" |
|
multiplier = 30 |
|
|
|
elif "year_month" in self.config.name: |
|
x_time_unit = "years" |
|
y_time_unit = "months" |
|
multiplier = 12 |
|
|
|
elif "decade_year" in self.config.name: |
|
x_time_unit = "decades" |
|
y_time_unit = "years" |
|
multiplier = 10 |
|
|
|
for key, x in enumerate(range(0, 100)): |
|
yield key, { |
|
"x": x, |
|
"x_time_unit": x_time_unit, |
|
"y": multiplier*x, |
|
"y_time_unit": y_time_unit, |
|
} |
|
|