Update genmix50k.py
Browse files- genmix50k.py +16 -17
genmix50k.py
CHANGED
@@ -2,9 +2,6 @@ import os
|
|
2 |
import json
|
3 |
import datasets
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
_DESCRIPTION = """
|
9 |
"""
|
10 |
|
@@ -29,19 +26,19 @@ class GenMix50k(datasets.GeneratorBasedBuilder):
|
|
29 |
BUILDER_CONFIGS = [
|
30 |
GenMix50kConfig(
|
31 |
name="translation",
|
32 |
-
data_dir="./
|
33 |
features=_FEATURES,
|
34 |
citation=_CITATION
|
35 |
),
|
36 |
GenMix50kConfig(
|
37 |
name="dialogue",
|
38 |
-
data_dir="./
|
39 |
features=_FEATURES,
|
40 |
citation=_CITATION
|
41 |
),
|
42 |
GenMix50kConfig(
|
43 |
name="summarization",
|
44 |
-
data_dir="./
|
45 |
features=_FEATURES,
|
46 |
citation=_CITATION
|
47 |
)
|
@@ -59,22 +56,24 @@ class GenMix50k(datasets.GeneratorBasedBuilder):
|
|
59 |
|
60 |
def _split_generators(self, dl_manager: datasets.DownloadManager):
|
61 |
"""Returns SplitGenerators"""
|
62 |
-
data_dir = dl_manager.manual_dir
|
63 |
path_kv = {
|
64 |
-
datasets.Split.TRAIN: os.path.join(data_dir,
|
65 |
-
datasets.Split.VALIDATION: os.path.join(data_dir,
|
66 |
-
datasets.Split.TEST: os.path.join(data_dir,
|
67 |
}
|
68 |
|
69 |
-
|
70 |
for split, path in path_kv.items():
|
71 |
-
if
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
-
return
|
75 |
-
datasets.SplitGenerator(name=k, gen_kwargs={"filepath": v})
|
76 |
-
for k, v in path_kv.items()
|
77 |
-
]
|
78 |
|
79 |
def _generate_examples(self, filepath):
|
80 |
with open(filepath, encoding="utf-8") as f:
|
|
|
2 |
import json
|
3 |
import datasets
|
4 |
|
|
|
|
|
|
|
5 |
_DESCRIPTION = """
|
6 |
"""
|
7 |
|
|
|
26 |
BUILDER_CONFIGS = [
|
27 |
GenMix50kConfig(
|
28 |
name="translation",
|
29 |
+
data_dir="./translation",
|
30 |
features=_FEATURES,
|
31 |
citation=_CITATION
|
32 |
),
|
33 |
GenMix50kConfig(
|
34 |
name="dialogue",
|
35 |
+
data_dir="./dialogue",
|
36 |
features=_FEATURES,
|
37 |
citation=_CITATION
|
38 |
),
|
39 |
GenMix50kConfig(
|
40 |
name="summarization",
|
41 |
+
data_dir="./summarization",
|
42 |
features=_FEATURES,
|
43 |
citation=_CITATION
|
44 |
)
|
|
|
56 |
|
57 |
def _split_generators(self, dl_manager: datasets.DownloadManager):
|
58 |
"""Returns SplitGenerators"""
|
59 |
+
data_dir = os.path.join(dl_manager.manual_dir, self.config.name)
|
60 |
path_kv = {
|
61 |
+
datasets.Split.TRAIN: os.path.join(data_dir, "train.json"),
|
62 |
+
datasets.Split.VALIDATION: os.path.join(data_dir, "valid.json"),
|
63 |
+
datasets.Split.TEST: os.path.join(data_dir, "test.json")
|
64 |
}
|
65 |
|
66 |
+
splits = []
|
67 |
for split, path in path_kv.items():
|
68 |
+
if os.path.isfile(path):
|
69 |
+
splits.append(datasets.SplitGenerator(name=split, gen_kwargs={"filepath": path}))
|
70 |
+
else:
|
71 |
+
print(f"Warning: File not found for {split} split: {path}")
|
72 |
+
|
73 |
+
if not splits:
|
74 |
+
raise datasets.data_files.DataFilesNotFoundError(f"No valid data files found in {data_dir} for splits: {path_kv.keys()}")
|
75 |
|
76 |
+
return splits
|
|
|
|
|
|
|
77 |
|
78 |
def _generate_examples(self, filepath):
|
79 |
with open(filepath, encoding="utf-8") as f:
|