Datasets:

Modalities:
Text
Formats:
parquet
Languages:
English
ArXiv:
Libraries:
Datasets
pandas
License:
albertvillanova HF staff commited on
Commit
a47c900
1 Parent(s): 4d4ed1b

Delete loading script

Browse files
Files changed (1) hide show
  1. ai2_arc.py +0 -132
ai2_arc.py DELETED
@@ -1,132 +0,0 @@
1
- """TODO(arc): Add a description here."""
2
-
3
-
4
- import json
5
- import os
6
-
7
- import datasets
8
-
9
-
10
- # TODO(ai2_arc): BibTeX citation
11
- _CITATION = """\
12
- @article{allenai:arc,
13
- author = {Peter Clark and Isaac Cowhey and Oren Etzioni and Tushar Khot and
14
- Ashish Sabharwal and Carissa Schoenick and Oyvind Tafjord},
15
- title = {Think you have Solved Question Answering? Try ARC, the AI2 Reasoning Challenge},
16
- journal = {arXiv:1803.05457v1},
17
- year = {2018},
18
- }
19
- """
20
-
21
- # TODO(ai2_arc):
22
- _DESCRIPTION = """\
23
- A new dataset of 7,787 genuine grade-school level, multiple-choice science questions, assembled to encourage research in
24
- advanced question-answering. The dataset is partitioned into a Challenge Set and an Easy Set, where the former contains
25
- only questions answered incorrectly by both a retrieval-based algorithm and a word co-occurrence algorithm. We are also
26
- including a corpus of over 14 million science sentences relevant to the task, and an implementation of three neural baseline models for this dataset. We pose ARC as a challenge to the community.
27
- """
28
-
29
- _URL = "https://s3-us-west-2.amazonaws.com/ai2-website/data/ARC-V1-Feb2018.zip"
30
-
31
-
32
- class Ai2ArcConfig(datasets.BuilderConfig):
33
- """BuilderConfig for Ai2ARC."""
34
-
35
- def __init__(self, **kwargs):
36
- """BuilderConfig for Ai2Arc.
37
-
38
- Args:
39
- **kwargs: keyword arguments forwarded to super.
40
- """
41
- super(Ai2ArcConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
42
-
43
-
44
- class Ai2Arc(datasets.GeneratorBasedBuilder):
45
- """TODO(arc): Short description of my dataset."""
46
-
47
- # TODO(arc): Set up version.
48
- VERSION = datasets.Version("1.0.0")
49
- BUILDER_CONFIGS = [
50
- Ai2ArcConfig(
51
- name="ARC-Challenge",
52
- description="""\
53
- Challenge Set of 2590 “hard” questions (those that both a retrieval and a co-occurrence method fail to answer correctly)
54
- """,
55
- ),
56
- Ai2ArcConfig(
57
- name="ARC-Easy",
58
- description="""\
59
- Easy Set of 5197 questions
60
- """,
61
- ),
62
- ]
63
-
64
- def _info(self):
65
- # TODO(ai2_arc): Specifies the datasets.DatasetInfo object
66
- return datasets.DatasetInfo(
67
- # This is the description that will appear on the datasets page.
68
- description=_DESCRIPTION,
69
- # datasets.features.FeatureConnectors
70
- features=datasets.Features(
71
- {
72
- "id": datasets.Value("string"),
73
- "question": datasets.Value("string"),
74
- "choices": datasets.features.Sequence(
75
- {"text": datasets.Value("string"), "label": datasets.Value("string")}
76
- ),
77
- "answerKey": datasets.Value("string")
78
- # These are the features of your dataset like images, labels ...
79
- }
80
- ),
81
- # If there's a common (input, target) tuple from the features,
82
- # specify them here. They'll be used if as_supervised=True in
83
- # builder.as_dataset.
84
- supervised_keys=None,
85
- # Homepage of the dataset for documentation
86
- homepage="https://allenai.org/data/arc",
87
- citation=_CITATION,
88
- )
89
-
90
- def _split_generators(self, dl_manager):
91
- """Returns SplitGenerators."""
92
- # TODO(ai2_arc): Downloads the data and defines the splits
93
- # dl_manager is a datasets.download.DownloadManager that can be used to
94
- # download and extract URLs
95
- dl_dir = dl_manager.download_and_extract(_URL)
96
- data_dir = os.path.join(dl_dir, "ARC-V1-Feb2018-2")
97
- return [
98
- datasets.SplitGenerator(
99
- name=datasets.Split.TRAIN,
100
- # These kwargs will be passed to _generate_examples
101
- gen_kwargs={"filepath": os.path.join(data_dir, self.config.name, self.config.name + "-Train.jsonl")},
102
- ),
103
- datasets.SplitGenerator(
104
- name=datasets.Split.TEST,
105
- # These kwargs will be passed to _generate_examples
106
- gen_kwargs={"filepath": os.path.join(data_dir, self.config.name, self.config.name + "-Test.jsonl")},
107
- ),
108
- datasets.SplitGenerator(
109
- name=datasets.Split.VALIDATION,
110
- # These kwargs will be passed to _generate_examples
111
- gen_kwargs={"filepath": os.path.join(data_dir, self.config.name, self.config.name + "-Dev.jsonl")},
112
- ),
113
- ]
114
-
115
- def _generate_examples(self, filepath):
116
- """Yields examples."""
117
- # TODO(ai2_arc): Yields (key, example) tuples from the dataset
118
- with open(filepath, encoding="utf-8") as f:
119
- for row in f:
120
- data = json.loads(row)
121
- answerkey = data["answerKey"]
122
- id_ = data["id"]
123
- question = data["question"]["stem"]
124
- choices = data["question"]["choices"]
125
- text_choices = [choice["text"] for choice in choices]
126
- label_choices = [choice["label"] for choice in choices]
127
- yield id_, {
128
- "id": id_,
129
- "answerKey": answerkey,
130
- "question": question,
131
- "choices": {"text": text_choices, "label": label_choices},
132
- }