Delete genmix50k.py
Browse files- genmix50k.py +0 -82
genmix50k.py
DELETED
@@ -1,82 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
import json
|
3 |
-
import datasets
|
4 |
-
|
5 |
-
_DESCRIPTION = """
|
6 |
-
"""
|
7 |
-
|
8 |
-
_CITATION = """
|
9 |
-
"""
|
10 |
-
|
11 |
-
_LICENCE = """
|
12 |
-
"""
|
13 |
-
|
14 |
-
_FEATURES = datasets.Features({
|
15 |
-
"x": datasets.Value(dtype="string"),
|
16 |
-
"y": datasets.Value(dtype="string")
|
17 |
-
})
|
18 |
-
|
19 |
-
class GenMix50kConfig(datasets.BuilderConfig):
|
20 |
-
def __init__(self, features, citation, **kwargs):
|
21 |
-
super(GenMix50kConfig, self).__init__(version=datasets.Version("1.0.3"), **kwargs)
|
22 |
-
self.features = features
|
23 |
-
self.citation = citation
|
24 |
-
|
25 |
-
class GenMix50k(datasets.GeneratorBasedBuilder):
|
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 |
-
)
|
45 |
-
]
|
46 |
-
|
47 |
-
def _info(self) -> datasets.DatasetInfo:
|
48 |
-
"""Returns the dataset metadata."""
|
49 |
-
return datasets.DatasetInfo(
|
50 |
-
description=_DESCRIPTION,
|
51 |
-
features=self.config.features,
|
52 |
-
citation=self.config.citation,
|
53 |
-
license=_LICENCE,
|
54 |
-
supervised_keys=None
|
55 |
-
)
|
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:
|
80 |
-
for idx, line in enumerate(f):
|
81 |
-
example = json.loads(line)
|
82 |
-
yield idx, example
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|