Datasets:
Update time_series_library.py
Browse files- time_series_library.py +25 -17
time_series_library.py
CHANGED
|
@@ -24,28 +24,36 @@ class TimeSeriesLibrary(GeneratorBasedBuilder):
|
|
| 24 |
|
| 25 |
def _split_generators(self, dl_manager):
|
| 26 |
dfiles = self.config.data_files
|
| 27 |
-
files = dfiles if isinstance(dfiles, (list, tuple)) else [dfiles]
|
| 28 |
|
| 29 |
-
def
|
| 30 |
-
for k in keys
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
return None
|
| 36 |
|
| 37 |
-
train_f =
|
| 38 |
-
|
| 39 |
-
|
|
|
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
return [SplitGenerator(Split.TRAIN, {"filepath": files})]
|
| 49 |
|
| 50 |
def _generate_examples(self, filepath, row_slice=None):
|
| 51 |
if isinstance(filepath, (list, tuple)):
|
|
|
|
| 24 |
|
| 25 |
def _split_generators(self, dl_manager):
|
| 26 |
dfiles = self.config.data_files
|
| 27 |
+
files = list(dfiles) if isinstance(dfiles, (list, tuple)) else [dfiles]
|
| 28 |
|
| 29 |
+
def find_and_pop(keys):
|
| 30 |
+
keys = [k.lower() for k in keys]
|
| 31 |
+
for i, f in enumerate(files):
|
| 32 |
+
name = os.path.basename(str(f)).lower()
|
| 33 |
+
if any(k in name for k in keys):
|
| 34 |
+
return files.pop(i)
|
| 35 |
return None
|
| 36 |
|
| 37 |
+
train_f = find_and_pop(["train"])
|
| 38 |
+
val_f = find_and_pop(["val", "valid", "validation"])
|
| 39 |
+
test_f = find_and_pop(["test"])
|
| 40 |
+
label_f = find_and_pop(["test_label", "label", "labels"])
|
| 41 |
|
| 42 |
+
gens = []
|
| 43 |
+
if train_f:
|
| 44 |
+
gens.append(SplitGenerator(name=Split.TRAIN, gen_kwargs={"filepath": train_f}))
|
| 45 |
+
if val_f:
|
| 46 |
+
gens.append(SplitGenerator(name=Split.VALIDATION, gen_kwargs={"filepath": val_f}))
|
| 47 |
+
if test_f:
|
| 48 |
+
gens.append(SplitGenerator(name=Split.TEST, gen_kwargs={"filepath": test_f}))
|
| 49 |
+
if label_f:
|
| 50 |
+
gens.append(SplitGenerator(name="test_label", gen_kwargs={"filepath": label_f}))
|
| 51 |
+
|
| 52 |
+
if not gens:
|
| 53 |
+
gens = [SplitGenerator(name=Split.TRAIN, gen_kwargs={"filepath": files})]
|
| 54 |
+
|
| 55 |
+
return gens
|
| 56 |
|
|
|
|
| 57 |
|
| 58 |
def _generate_examples(self, filepath, row_slice=None):
|
| 59 |
if isinstance(filepath, (list, tuple)):
|