MCPcopy Create free account
hub / github.com/OpenBitSys/BitDistiller / ASDiv

Class ASDiv

test/general/lm_eval/datasets/asdiv/asdiv.py:52–111  ·  view source on GitHub ↗

ASDiv: A Diverse Corpus for Evaluating and Developing English Math Word Problem Solvers

Source from the content-addressed store, hash-verified

50
51
52class ASDiv(datasets.GeneratorBasedBuilder):
53 """ASDiv: A Diverse Corpus for Evaluating and Developing English Math Word Problem Solvers"""
54
55 VERSION = datasets.Version("0.0.1")
56
57 BUILDER_CONFIGS = [
58 datasets.BuilderConfig(
59 name="asdiv",
60 version=VERSION,
61 description="A diverse corpus for evaluating and developing english math word problem solvers",
62 )
63 ]
64
65 def _info(self):
66 features = datasets.Features(
67 {
68 "body": datasets.Value("string"),
69 "question": datasets.Value("string"),
70 "solution_type": datasets.Value("string"),
71 "answer": datasets.Value("string"),
72 "formula": datasets.Value("string"),
73 }
74 )
75 return datasets.DatasetInfo(
76 description=_DESCRIPTION,
77 features=features,
78 homepage=_HOMEPAGE,
79 license=_LICENSE,
80 citation=_CITATION,
81 )
82
83 def _split_generators(self, dl_manager):
84 urls = _URLS
85 data_dir = dl_manager.download_and_extract(urls)
86 base_filepath = "nlu-asdiv-dataset-55790e5270bb91ccfa5053194b25732534696b50"
87 return [
88 datasets.SplitGenerator(
89 name=datasets.Split.VALIDATION,
90 # These kwargs will be passed to _generate_examples
91 gen_kwargs={
92 "filepath": os.path.join(
93 data_dir, base_filepath, "dataset", "ASDiv.xml"
94 ),
95 "split": datasets.Split.VALIDATION,
96 },
97 ),
98 ]
99
100 # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
101 def _generate_examples(self, filepath, split):
102 tree = ET.parse(filepath)
103 root = tree.getroot()
104 for key, problem in enumerate(root.iter("Problem")):
105 yield key, {
106 "body": problem.find("Body").text,
107 "question": problem.find("Question").text,
108 "solution_type": problem.find("Solution-Type").text,
109 "answer": problem.find("Answer").text,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected