jpcorb20 commited on
Commit
30c4857
·
verified ·
1 Parent(s): 46ef82b

Update SIMORD.py

Browse files
Files changed (1) hide show
  1. SIMORD.py +26 -19
SIMORD.py CHANGED
@@ -219,33 +219,40 @@ class SimordMerge(datasets.GeneratorBasedBuilder):
219
  citation=_CITATION,
220
  )
221
 
222
- def _split_generators(self, dl_manager: datasets.DownloadManager):
223
- data_dir = self.config.data_dir or os.getcwd()
224
-
225
- # Map from local file name → desired HF split name
 
 
 
 
226
  file_map = {
227
  "train.json": ("train", datasets.Split.TRAIN),
228
- "dev.json": ("test1", "test1"), # expose dev as "test1"
229
- "test.json": ("test2", "test2"), # expose test as "test2"
230
  }
231
-
232
- # Download upstream corpora once
233
- aci_dir = dl_manager.download_and_extract(ACI_BENCH_URL)
234
- primock_dir = dl_manager.download_and_extract(PRIMOCK_URL)
235
- self._transcript_dict = {}
236
- self._transcript_dict.update(_build_aci_transcript_dict(aci_dir))
237
- self._transcript_dict.update(_build_primock_transcript_dict(primock_dir))
238
-
239
  splits = []
240
- for fname, (exposed_name, hf_split) in file_map.items():
241
- path = os.path.join(data_dir, fname)
242
- if os.path.isfile(path):
 
243
  splits.append(
244
  datasets.SplitGenerator(
245
- name=hf_split,
246
- gen_kwargs={"ann_path": path},
247
  )
248
  )
 
 
 
 
 
 
 
 
 
249
  return splits
250
 
251
  def _generate_examples(self, ann_path: str):
 
219
  citation=_CITATION,
220
  )
221
 
222
+ def _split_generators(self, dl_manager):
223
+ base = os.path.dirname(os.path.realpath(__file__))
224
+ data_dir = self.config.data_dir or "data"
225
+ data_dir = os.path.join(base, data_dir)
226
+
227
+ if not os.path.isdir(data_dir):
228
+ raise FileNotFoundError(f"data_dir not found: {data_dir}")
229
+
230
  file_map = {
231
  "train.json": ("train", datasets.Split.TRAIN),
232
+ "dev.json": ("test1", "test1"),
233
+ "test.json": ("test2", "test2"),
234
  }
235
+
 
 
 
 
 
 
 
236
  splits = []
237
+ missing = []
238
+ for fname, (exposed, split_name) in file_map.items():
239
+ p = os.path.join(data_dir, fname)
240
+ if os.path.isfile(p):
241
  splits.append(
242
  datasets.SplitGenerator(
243
+ name=split_name,
244
+ gen_kwargs={"ann_path": p, "exposed_name": exposed},
245
  )
246
  )
247
+ else:
248
+ missing.append(fname)
249
+
250
+ if not splits:
251
+ raise FileNotFoundError(
252
+ f"No split files found under {data_dir}. "
253
+ f"Expected one of: {', '.join(file_map.keys())}. Missing: {missing}"
254
+ )
255
+
256
  return splits
257
 
258
  def _generate_examples(self, ann_path: str):