Delete loading script
Browse files
asdiv.py
DELETED
|
@@ -1,111 +0,0 @@
|
|
| 1 |
-
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
| 2 |
-
#
|
| 3 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
-
# you may not use this file except in compliance with the License.
|
| 5 |
-
# You may obtain a copy of the License at
|
| 6 |
-
#
|
| 7 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
-
#
|
| 9 |
-
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
-
# See the License for the specific language governing permissions and
|
| 13 |
-
# limitations under the License.
|
| 14 |
-
"""ASDIV dataset."""
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
import os
|
| 18 |
-
import xml.etree.ElementTree as ET
|
| 19 |
-
|
| 20 |
-
import datasets
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
_CITATION = """\
|
| 24 |
-
@misc{miao2021diverse,
|
| 25 |
-
title={A Diverse Corpus for Evaluating and Developing English Math Word Problem Solvers},
|
| 26 |
-
author={Shen-Yun Miao and Chao-Chun Liang and Keh-Yih Su},
|
| 27 |
-
year={2021},
|
| 28 |
-
eprint={2106.15772},
|
| 29 |
-
archivePrefix={arXiv},
|
| 30 |
-
primaryClass={cs.AI}
|
| 31 |
-
}
|
| 32 |
-
"""
|
| 33 |
-
|
| 34 |
-
_DESCRIPTION = """\
|
| 35 |
-
ASDiv (Academia Sinica Diverse MWP Dataset) is a diverse (in terms of both language
|
| 36 |
-
patterns and problem types) English math word problem (MWP) corpus for evaluating
|
| 37 |
-
the capability of various MWP solvers. Existing MWP corpora for studying AI progress
|
| 38 |
-
remain limited either in language usage patterns or in problem types. We thus present
|
| 39 |
-
a new English MWP corpus with 2,305 MWPs that cover more text patterns and most problem
|
| 40 |
-
types taught in elementary school. Each MWP is annotated with its problem type and grade
|
| 41 |
-
level (for indicating the level of difficulty).
|
| 42 |
-
"""
|
| 43 |
-
|
| 44 |
-
_HOMEPAGE = "https://github.com/chaochun/nlu-asdiv-dataset"
|
| 45 |
-
|
| 46 |
-
# License declared at https://github.com/chaochun/nlu-asdiv-dataset/blob/master/README.md
|
| 47 |
-
_LICENSE = "CC BY-NC 4.0"
|
| 48 |
-
|
| 49 |
-
_URLS = "https://github.com/chaochun/nlu-asdiv-dataset/archive/55790e5270bb91ccfa5053194b25732534696b50.zip"
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
class 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,
|
| 110 |
-
"formula": problem.find("Formula").text,
|
| 111 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|