Datasets:

ArneBinder commited on
Commit
052163d
1 Parent(s): e917db0

fix: join directroy / files with base_dir

Browse files
Files changed (1) hide show
  1. brat.py +9 -4
brat.py CHANGED
@@ -18,7 +18,7 @@ class BratConfig(BuilderConfig):
18
  description: Optional[str] = None
19
  citation: Optional[str] = None
20
  homepage: Optional[str] = None
21
-
22
  # paths to directories or files per split (relative to url or data_dir)
23
  split_paths: Optional[Dict[str, Union[str, List[str]]]] = None
24
  file_name_blacklist: Optional[List[str]] = None
@@ -276,10 +276,15 @@ class Brat(datasets.GeneratorBasedBuilder):
276
  if files is None:
277
  if directory is None:
278
  raise ValueError("Either files or directory has to be provided.")
279
- _files = glob.glob(f"{directory}/*.{self.config.ann_file_extension}")
 
280
  files = sorted(path.splitext(fn)[0] for fn in _files)
281
- elif directory is not None:
282
- raise ValueError("Only one of files or directory can be provided.")
 
 
 
 
283
 
284
  for filename in files:
285
  basename = path.basename(filename)
 
18
  description: Optional[str] = None
19
  citation: Optional[str] = None
20
  homepage: Optional[str] = None
21
+
22
  # paths to directories or files per split (relative to url or data_dir)
23
  split_paths: Optional[Dict[str, Union[str, List[str]]]] = None
24
  file_name_blacklist: Optional[List[str]] = None
 
276
  if files is None:
277
  if directory is None:
278
  raise ValueError("Either files or directory has to be provided.")
279
+ _directory = path.join(base_dir, directory)
280
+ _files = glob.glob(f"{_directory}/*.{self.config.ann_file_extension}")
281
  files = sorted(path.splitext(fn)[0] for fn in _files)
282
+ if len(files) == 0:
283
+ raise ValueError(f"No files found in directory: {_directory}")
284
+ else:
285
+ if directory is not None:
286
+ raise ValueError("Only one of files or directory can be provided.")
287
+ files = [path.join(base_dir, fn) for fn in files]
288
 
289
  for filename in files:
290
  basename = path.basename(filename)