Update olympiads-ref.py (#7)
Browse files- Update olympiads-ref.py (343f75f7ac701335d58b42c433ab99713c7c560c)
- Update datasets loading script (e2ba62e537a4c4ab41a565a7421af90efd793397)
Co-authored-by: Javi Lau <LxYxvv@users.noreply.huggingface.co>
- olympiads-ref.py +7 -6
olympiads-ref.py
CHANGED
|
@@ -54,7 +54,8 @@ class OlympiadReferenceDataset(datasets.GeneratorBasedBuilder):
|
|
| 54 |
"problem": datasets.Value("string"),
|
| 55 |
"solution": datasets.Value("string"),
|
| 56 |
"year": datasets.Value("int32"),
|
| 57 |
-
"tier": datasets.Value("int32")
|
|
|
|
| 58 |
}
|
| 59 |
)
|
| 60 |
|
|
@@ -72,23 +73,22 @@ class OlympiadReferenceDataset(datasets.GeneratorBasedBuilder):
|
|
| 72 |
repo_files = self._hfapi.list_repo_files(repo_id="AI-MO/olympiads-ref", repo_type="dataset")
|
| 73 |
seg_jsonl_files = [s for s in repo_files if self.pattern.match(s)]
|
| 74 |
|
| 75 |
-
|
| 76 |
-
data_files = dl_manager.download_and_extract(data_urls)
|
| 77 |
|
| 78 |
return [
|
| 79 |
datasets.SplitGenerator(
|
| 80 |
name=datasets.Split.TRAIN,
|
| 81 |
gen_kwargs={
|
| 82 |
-
"
|
| 83 |
"split": "train",
|
| 84 |
},
|
| 85 |
)
|
| 86 |
]
|
| 87 |
|
| 88 |
-
def _generate_examples(self,
|
| 89 |
key = 0
|
| 90 |
|
| 91 |
-
for file in
|
| 92 |
with open(file, "r", encoding="utf-8") as f:
|
| 93 |
for line in f:
|
| 94 |
data = json.loads(line)
|
|
@@ -99,5 +99,6 @@ class OlympiadReferenceDataset(datasets.GeneratorBasedBuilder):
|
|
| 99 |
"solution": data.get("solution"),
|
| 100 |
"year": data.get("year"),
|
| 101 |
"tier": data.get("tier"),
|
|
|
|
| 102 |
}
|
| 103 |
key += 1
|
|
|
|
| 54 |
"problem": datasets.Value("string"),
|
| 55 |
"solution": datasets.Value("string"),
|
| 56 |
"year": datasets.Value("int32"),
|
| 57 |
+
"tier": datasets.Value("int32"),
|
| 58 |
+
"resource_path": datasets.Value("string")
|
| 59 |
}
|
| 60 |
)
|
| 61 |
|
|
|
|
| 73 |
repo_files = self._hfapi.list_repo_files(repo_id="AI-MO/olympiads-ref", repo_type="dataset")
|
| 74 |
seg_jsonl_files = [s for s in repo_files if self.pattern.match(s)]
|
| 75 |
|
| 76 |
+
data_files = [(sjf, dl_manager.extract(dl_manager.download(data_root_path / sjf))) for sjf in seg_jsonl_files]
|
|
|
|
| 77 |
|
| 78 |
return [
|
| 79 |
datasets.SplitGenerator(
|
| 80 |
name=datasets.Split.TRAIN,
|
| 81 |
gen_kwargs={
|
| 82 |
+
"data_files": data_files,
|
| 83 |
"split": "train",
|
| 84 |
},
|
| 85 |
)
|
| 86 |
]
|
| 87 |
|
| 88 |
+
def _generate_examples(self, data_files, split):
|
| 89 |
key = 0
|
| 90 |
|
| 91 |
+
for resource_path, file in data_files:
|
| 92 |
with open(file, "r", encoding="utf-8") as f:
|
| 93 |
for line in f:
|
| 94 |
data = json.loads(line)
|
|
|
|
| 99 |
"solution": data.get("solution"),
|
| 100 |
"year": data.get("year"),
|
| 101 |
"tier": data.get("tier"),
|
| 102 |
+
"resource_path": resource_path
|
| 103 |
}
|
| 104 |
key += 1
|