You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""Create an AnnotationSet from a folder of annotation files.
226
+
227
+
Parameters
228
+
----------
229
+
folder : PathLike
230
+
The path to the folder containing the annotation files.
231
+
parser : Callable[[Path], Annotation]
232
+
A function that takes a file path and returns an Annotation object.
233
+
extension : Optional[str], optional
234
+
The file extension of the annotation files (e.g., ".json"). If provided, only files with this extension will be considered. If None, `is_ann_file` must be provided.
A function that takes a file path and returns True if the file is an annotation file. If provided, this function will be used to filter files. If None, `extension` must be provided.
237
+
recursive : bool, optional
238
+
Whether to search for annotation files recursively in subdirectories, by default False
239
+
verbose : bool, optional
240
+
Whether to print tqdm progress output during parsing, by default False
241
+
242
+
Returns
243
+
-------
244
+
AnnotationSet
245
+
A set of annotations parsed from the files in the folder.
246
+
247
+
Raises
248
+
------
249
+
ValueError
250
+
If the folder is not a directory or does not exist, if both `extension` and `is_ann_file` are None and if `extension` is provided but does not start with a dot.
251
+
"""
224
252
folder=Path(folder).expanduser().resolve()
225
253
226
-
assert (
227
-
folder.is_dir()
228
-
), f"Filepath '{folder}' is not a folder or does not exist."
254
+
ifnotfolder.is_dir():
255
+
raiseValueError(f"Path '{folder}' is not a folder or does not exist.")
256
+
257
+
ifextensionisNoneandis_ann_fileisNone:
258
+
raiseValueError("Either `extension` or `is_ann_file` must be provided.")
259
+
260
+
ifextensionisnotNone:
261
+
ifnotextension.startswith("."):
262
+
raiseValueError("`extension` must start with a dot.")
0 commit comments