Datasets:
hezheqi
commited on
Commit
·
62de422
1
Parent(s):
4e436fb
add dataset
Browse files- hf_cmmu_dataset.py +0 -46
hf_cmmu_dataset.py
DELETED
|
@@ -1,46 +0,0 @@
|
|
| 1 |
-
from datasets import DatasetBuilder, Features, Value, Sequence, DatasetInfo
|
| 2 |
-
import json
|
| 3 |
-
import os.path as osp
|
| 4 |
-
|
| 5 |
-
class HfCmmuDataset(DatasetBuilder):
|
| 6 |
-
def _info(self):
|
| 7 |
-
return DatasetInfo(
|
| 8 |
-
features=Features({
|
| 9 |
-
"type": Value("string"),
|
| 10 |
-
"class": Value("string"),
|
| 11 |
-
"grade_band": Value("string"),
|
| 12 |
-
"difficulty": Value("string"),
|
| 13 |
-
"answer": Value("string"),
|
| 14 |
-
"question_info": Value("string"),
|
| 15 |
-
"solution_info": Value("string"),
|
| 16 |
-
"options": Sequence(Value("string")),
|
| 17 |
-
"sub_questions": Sequence(Value("string")),
|
| 18 |
-
"id": Value("string"),
|
| 19 |
-
"images": Sequence(Value("string")),
|
| 20 |
-
"split": Value("string")
|
| 21 |
-
}),
|
| 22 |
-
)
|
| 23 |
-
|
| 24 |
-
def _split_generators(self, dl_manager):
|
| 25 |
-
# Define the splits here if needed
|
| 26 |
-
return []
|
| 27 |
-
|
| 28 |
-
def _generate_examples(self):
|
| 29 |
-
# Here, you'll need to write code to read and yield each example
|
| 30 |
-
# from your jsonl files.
|
| 31 |
-
jsonl_files = [
|
| 32 |
-
"biology.jsonl",
|
| 33 |
-
"chemistry.jsonl",
|
| 34 |
-
"geography.jsonl",
|
| 35 |
-
"history.jsonl",
|
| 36 |
-
"math.jsonl",
|
| 37 |
-
"physics.jsonl",
|
| 38 |
-
"politics.jsonl"
|
| 39 |
-
]
|
| 40 |
-
for file_path in jsonl_files: # Add all your jsonl files here
|
| 41 |
-
with open(osp.join('val', file_path), "r", encoding="utf-8") as f:
|
| 42 |
-
for idx, line in enumerate(f):
|
| 43 |
-
record = json.loads(line)
|
| 44 |
-
yield idx, record
|
| 45 |
-
|
| 46 |
-
dataset = HfCmmuDataset()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|