-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
32 lines (25 loc) · 819 Bytes
/
utils.py
File metadata and controls
32 lines (25 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from enum import Enum
from segeval.data import load_nested_folders_dict, input_linear_mass_json
from segeval.data.jsonutils import output_linear_mass_json
class LoadTypeEnum(Enum):
fold = 0,
json = 1
def load_dataset(path, load_type=LoadTypeEnum.fold):
"""
Load data according to load type.
:param path: file path or file fold path
:param load_type: fold or json (LoadTypeEnum)
:return: dataset
"""
if load_type == LoadTypeEnum.fold:
return load_nested_folders_dict(path, filetype="tsv")
else:
return input_linear_mass_json(path)
def write_dataset(dataset, file_path="./data/dataset.json"):
"""
Write dataset.
:param dataset: dataset
:param file_path: des file path
:return: None
"""
output_linear_mass_json(file_path, dataset)