Datasets:
Ramon Pires
commited on
Commit
·
8f36884
1
Parent(s):
1ac418e
Remove enem.p
Browse files
enem.py
DELETED
|
@@ -1,108 +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 |
-
"""ENEM dataset."""
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
import json
|
| 18 |
-
|
| 19 |
-
import datasets
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
_CITATION = """\
|
| 23 |
-
"""
|
| 24 |
-
|
| 25 |
-
_DESCRIPTION = """\
|
| 26 |
-
The study explores the capabilities of Language Models (LMs) in solving
|
| 27 |
-
high-stakes multiple-choice tests, using the Exame Nacional do Ensino Médio
|
| 28 |
-
(ENEM) as a case study. The ENEM is a multidisciplinary entrance examination
|
| 29 |
-
widely adopted by Brazilian universities, which poses challenging tasks for
|
| 30 |
-
LMs since its questions may span multiple fields of knowledge, requiring
|
| 31 |
-
understanding of information from diverse domains.
|
| 32 |
-
"""
|
| 33 |
-
|
| 34 |
-
_HOMEPAGE = "https://github.com/piresramon/gpt-4-enem"
|
| 35 |
-
|
| 36 |
-
# TODO: Add the licence for the dataset here if you can find it
|
| 37 |
-
_LICENSE = ""
|
| 38 |
-
|
| 39 |
-
_URL_2022 = "https://huggingface.co/datasets/maritaca-ai/enem/raw/main/2022.jsonl"
|
| 40 |
-
_URL_2023 = "https://huggingface.co/datasets/maritaca-ai/enem/raw/main/2023.jsonl"
|
| 41 |
-
|
| 42 |
-
class ENEM(datasets.GeneratorBasedBuilder):
|
| 43 |
-
|
| 44 |
-
VERSION = datasets.Version("0.0.1")
|
| 45 |
-
|
| 46 |
-
BUILDER_CONFIGS = [
|
| 47 |
-
datasets.BuilderConfig(name="2022", data_dir=_URL_2022, version=VERSION, description="The ENEM 2022 dataset"),
|
| 48 |
-
datasets.BuilderConfig(name="2023", data_dir=_URL_2023, version=VERSION, description="The ENEM 2023 dataset"),
|
| 49 |
-
]
|
| 50 |
-
|
| 51 |
-
def _info(self):
|
| 52 |
-
features = datasets.Features(
|
| 53 |
-
{
|
| 54 |
-
"id": datasets.Value("string"),
|
| 55 |
-
"exam": datasets.Value("string"),
|
| 56 |
-
"IU": datasets.Value("bool"),
|
| 57 |
-
"question": datasets.Value("string"),
|
| 58 |
-
"alternatives": datasets.features.Sequence(
|
| 59 |
-
datasets.Value("string")
|
| 60 |
-
),
|
| 61 |
-
"figures": datasets.features.Sequence(
|
| 62 |
-
datasets.Value("string")
|
| 63 |
-
),
|
| 64 |
-
"description": datasets.features.Sequence(
|
| 65 |
-
datasets.Value("string")
|
| 66 |
-
),
|
| 67 |
-
"label": datasets.Value("string"),
|
| 68 |
-
}
|
| 69 |
-
)
|
| 70 |
-
return datasets.DatasetInfo(
|
| 71 |
-
description=f"{_DESCRIPTION}\n{self.config.description}",
|
| 72 |
-
features=features,
|
| 73 |
-
homepage=_HOMEPAGE,
|
| 74 |
-
license=_LICENSE,
|
| 75 |
-
citation=_CITATION,
|
| 76 |
-
)
|
| 77 |
-
|
| 78 |
-
def _split_generators(self, dl_manager):
|
| 79 |
-
dl_dir = dl_manager.download_and_extract(self.config.data_dir) or ""
|
| 80 |
-
print(f'{dl_dir}')
|
| 81 |
-
return [
|
| 82 |
-
datasets.SplitGenerator(
|
| 83 |
-
name=datasets.Split.TRAIN,
|
| 84 |
-
# These kwargs will be passed to _generate_examples
|
| 85 |
-
gen_kwargs={
|
| 86 |
-
"filepath": dl_manager.download_and_extract(dl_dir),
|
| 87 |
-
# "data_path": dl_manager.download_and_extract(dl_dir),
|
| 88 |
-
"split": datasets.Split.TRAIN,
|
| 89 |
-
},
|
| 90 |
-
),
|
| 91 |
-
]
|
| 92 |
-
|
| 93 |
-
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
| 94 |
-
def _generate_examples(self, filepath, split):
|
| 95 |
-
with open(filepath, encoding="utf-8") as f:
|
| 96 |
-
for key, row in enumerate(f):
|
| 97 |
-
data = json.loads(row)
|
| 98 |
-
print(f'{data=}')
|
| 99 |
-
yield key, {
|
| 100 |
-
"id": data["id"],
|
| 101 |
-
"exam": data["exam"],
|
| 102 |
-
"IU": data["IU"],
|
| 103 |
-
"question": data["question"],
|
| 104 |
-
"alternatives": data["alternatives"],
|
| 105 |
-
"figures": data["figures"],
|
| 106 |
-
"description": data["description"],
|
| 107 |
-
"label": data["label"],
|
| 108 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|