jordiclive
commited on
Commit
•
7a0d6d4
1
Parent(s):
76e185d
Update my_uspto.py
Browse files- my_uspto.py +15 -48
my_uspto.py
CHANGED
@@ -1,77 +1,64 @@
|
|
1 |
-
|
2 |
import json
|
3 |
-
import datasets
|
4 |
import os
|
5 |
from glob import glob
|
|
|
|
|
6 |
import zstandard as zstd
|
|
|
7 |
from datasets.utils import Version
|
8 |
-
import io
|
9 |
from huggingface_hub import snapshot_download
|
10 |
|
11 |
|
12 |
-
class
|
13 |
VERSION = Version("1.0.0")
|
14 |
|
15 |
def _info(self):
|
16 |
return datasets.DatasetInfo(
|
17 |
-
description="
|
18 |
features=datasets.Features(
|
19 |
{
|
20 |
"text": datasets.Value("string"),
|
21 |
-
|
22 |
}
|
23 |
),
|
24 |
supervised_keys=None,
|
25 |
-
|
26 |
)
|
27 |
|
28 |
def _split_generators(self, dl_manager):
|
29 |
-
snapshot_download(repo_id="
|
|
|
|
|
|
|
30 |
return [
|
31 |
datasets.SplitGenerator(
|
32 |
name=datasets.Split.TRAIN,
|
33 |
-
# These kwargs will be passed to _generate_examples
|
34 |
gen_kwargs={
|
35 |
-
"data_dir": "train",
|
36 |
"split": None,
|
37 |
},
|
38 |
-
|
39 |
),
|
40 |
datasets.SplitGenerator(
|
41 |
name="validation_pile",
|
42 |
-
# These kwargs will be passed to _generate_examples
|
43 |
gen_kwargs={
|
44 |
-
"data_dir": "val",
|
45 |
"split": "pile",
|
46 |
},
|
47 |
),
|
48 |
datasets.SplitGenerator(
|
49 |
name="validation_domain",
|
50 |
-
# These kwargs will be passed to _generate_examples
|
51 |
gen_kwargs={
|
52 |
-
"data_dir": "val",
|
53 |
"split": "domain",
|
54 |
},
|
55 |
),
|
56 |
datasets.SplitGenerator(
|
57 |
name="test_pile",
|
58 |
-
|
59 |
-
gen_kwargs={
|
60 |
-
"data_dir": "test_pile",
|
61 |
-
"split": "pile"
|
62 |
-
},
|
63 |
-
|
64 |
),
|
65 |
datasets.SplitGenerator(
|
66 |
name="test_domain",
|
67 |
-
|
68 |
-
gen_kwargs={
|
69 |
-
"data_dir": "test_domain",
|
70 |
-
"split": "domain"
|
71 |
-
},
|
72 |
-
|
73 |
),
|
74 |
-
|
75 |
]
|
76 |
|
77 |
def _generate_examples(self, data_dir, split):
|
@@ -88,23 +75,3 @@ class MyUSPTODataset(GeneratorBasedBuilder):
|
|
88 |
data = json.loads(line)
|
89 |
idx += 1
|
90 |
yield idx, data
|
91 |
-
|
92 |
-
|
93 |
-
# if __name__ == "__main__":
|
94 |
-
# b = datasets.load_dataset('/Users/jordanclive/Desktop/MDEL/my_uspto')
|
95 |
-
# # import os
|
96 |
-
# # import shutil
|
97 |
-
# # import glob
|
98 |
-
# # cache_directory = "/Users/jordanclive/.cache/huggingface/datasets"
|
99 |
-
# #
|
100 |
-
# # dataset = MyUSPTODataset()
|
101 |
-
# #
|
102 |
-
# # #
|
103 |
-
# # dataset = MyUSPTODataset()
|
104 |
-
# # dataset.download_and_prepare()
|
105 |
-
# # dataset = dataset.as_dataset()
|
106 |
-
# # # # x = 1
|
107 |
-
# # # print(dataset)
|
108 |
-
# # # print(dataset["train"][0])
|
109 |
-
# # # print(dataset["test"][0])
|
110 |
-
# # # print(dataset["validation"][0])
|
|
|
1 |
+
import io
|
2 |
import json
|
|
|
3 |
import os
|
4 |
from glob import glob
|
5 |
+
|
6 |
+
import datasets
|
7 |
import zstandard as zstd
|
8 |
+
from datasets import GeneratorBasedBuilder
|
9 |
from datasets.utils import Version
|
|
|
10 |
from huggingface_hub import snapshot_download
|
11 |
|
12 |
|
13 |
+
class PileDomainDataset(GeneratorBasedBuilder):
|
14 |
VERSION = Version("1.0.0")
|
15 |
|
16 |
def _info(self):
|
17 |
return datasets.DatasetInfo(
|
18 |
+
description="Pile Domain Dataset",
|
19 |
features=datasets.Features(
|
20 |
{
|
21 |
"text": datasets.Value("string"),
|
|
|
22 |
}
|
23 |
),
|
24 |
supervised_keys=None,
|
|
|
25 |
)
|
26 |
|
27 |
def _split_generators(self, dl_manager):
|
28 |
+
#snapshot_download(repo_id="Multi-Domain-Expert-Layers/uspto", repo_type="dataset")
|
29 |
+
# dl_manager.download_and_extract("https://huggingface.co/datasets/Multi-Domain-Expert-Layers/uspto/resolve/main/uspto.tar.gz")
|
30 |
+
dl_path = snapshot_download(repo_id="jordiclive/my_uspto", repo_type="dataset")
|
31 |
+
|
32 |
return [
|
33 |
datasets.SplitGenerator(
|
34 |
name=datasets.Split.TRAIN,
|
|
|
35 |
gen_kwargs={
|
36 |
+
"data_dir": os.path.join(dl_path, "data/train"),
|
37 |
"split": None,
|
38 |
},
|
|
|
39 |
),
|
40 |
datasets.SplitGenerator(
|
41 |
name="validation_pile",
|
|
|
42 |
gen_kwargs={
|
43 |
+
"data_dir": os.path.join(dl_path, "data/val"),
|
44 |
"split": "pile",
|
45 |
},
|
46 |
),
|
47 |
datasets.SplitGenerator(
|
48 |
name="validation_domain",
|
|
|
49 |
gen_kwargs={
|
50 |
+
"data_dir": os.path.join(dl_path, "data/val"),
|
51 |
"split": "domain",
|
52 |
},
|
53 |
),
|
54 |
datasets.SplitGenerator(
|
55 |
name="test_pile",
|
56 |
+
gen_kwargs={"data_dir": os.path.join(dl_path, "data/test"), "split": "pile"},
|
|
|
|
|
|
|
|
|
|
|
57 |
),
|
58 |
datasets.SplitGenerator(
|
59 |
name="test_domain",
|
60 |
+
gen_kwargs={"data_dir": os.path.join(dl_path, "data/test"), "split": "domain"},
|
|
|
|
|
|
|
|
|
|
|
61 |
),
|
|
|
62 |
]
|
63 |
|
64 |
def _generate_examples(self, data_dir, split):
|
|
|
75 |
data = json.loads(line)
|
76 |
idx += 1
|
77 |
yield idx, data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|