Datasets:
Size:
10B<n<100B
License:
Bugfix
Browse files- bertic_data.py +19 -15
bertic_data.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import datasets
|
2 |
import gzip
|
3 |
import json
|
|
|
4 |
_URL = "http://nl.ijs.si/nikola/dedup_hbs/"
|
5 |
_URLS = [
|
6 |
# "macocu.hbs.translit.dedup.lines.gz",
|
@@ -51,7 +52,6 @@ _CITATION = """
|
|
51 |
}"""
|
52 |
|
53 |
|
54 |
-
|
55 |
class BerticDataConfig(datasets.BuilderConfig):
|
56 |
"""BuilderConfig for Bertic data sample."""
|
57 |
|
@@ -66,6 +66,7 @@ class BerticDataConfig(datasets.BuilderConfig):
|
|
66 |
|
67 |
class BerticData(datasets.GeneratorBasedBuilder):
|
68 |
"""Bertic dataset, used for training Bertic model."""
|
|
|
69 |
VERSION = datasets.Version("1.0.0")
|
70 |
|
71 |
# This is an example of a dataset with multiple configurations.
|
@@ -81,13 +82,15 @@ class BerticData(datasets.GeneratorBasedBuilder):
|
|
81 |
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
82 |
BUILDER_CONFIGS = [
|
83 |
BerticDataConfig(
|
84 |
-
name=
|
85 |
-
subsets=[
|
86 |
version=VERSION,
|
87 |
-
description="All subsets"
|
88 |
-
)
|
|
|
89 |
|
90 |
self._URLS = _URLS
|
|
|
91 |
def _info(self):
|
92 |
features = datasets.Features(
|
93 |
{
|
@@ -101,23 +104,24 @@ class BerticData(datasets.GeneratorBasedBuilder):
|
|
101 |
citation=_CITATION,
|
102 |
)
|
103 |
|
104 |
-
def _split_generators(
|
105 |
-
|
|
|
106 |
urls_to_download = self._URLS
|
107 |
-
urls_to_download = {i
|
108 |
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
109 |
|
110 |
return [
|
111 |
datasets.SplitGenerator(
|
112 |
-
name=datasets.Split.TRAIN,
|
113 |
-
|
114 |
-
|
115 |
]
|
116 |
|
117 |
def _generate_examples(self, data_files):
|
118 |
-
key = 0
|
119 |
-
for name in data_files:
|
120 |
-
with gzip.open(name, "rb") as f:
|
121 |
for line in f.readlines():
|
122 |
yield key, {"text": line.decode("uft-8").strip()}
|
123 |
-
key += 1
|
|
|
1 |
import datasets
|
2 |
import gzip
|
3 |
import json
|
4 |
+
|
5 |
_URL = "http://nl.ijs.si/nikola/dedup_hbs/"
|
6 |
_URLS = [
|
7 |
# "macocu.hbs.translit.dedup.lines.gz",
|
|
|
52 |
}"""
|
53 |
|
54 |
|
|
|
55 |
class BerticDataConfig(datasets.BuilderConfig):
|
56 |
"""BuilderConfig for Bertic data sample."""
|
57 |
|
|
|
66 |
|
67 |
class BerticData(datasets.GeneratorBasedBuilder):
|
68 |
"""Bertic dataset, used for training Bertic model."""
|
69 |
+
|
70 |
VERSION = datasets.Version("1.0.0")
|
71 |
|
72 |
# This is an example of a dataset with multiple configurations.
|
|
|
82 |
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
83 |
BUILDER_CONFIGS = [
|
84 |
BerticDataConfig(
|
85 |
+
name="default",
|
86 |
+
subsets=["arxiv", "open-web-math", "algebraic-stack"],
|
87 |
version=VERSION,
|
88 |
+
description="All subsets",
|
89 |
+
)
|
90 |
+
]
|
91 |
|
92 |
self._URLS = _URLS
|
93 |
+
|
94 |
def _info(self):
|
95 |
features = datasets.Features(
|
96 |
{
|
|
|
104 |
citation=_CITATION,
|
105 |
)
|
106 |
|
107 |
+
def _split_generators(
|
108 |
+
self, dl_manager: datasets.DownloadManager
|
109 |
+
) -> List[datasets.SplitGenerator]:
|
110 |
urls_to_download = self._URLS
|
111 |
+
urls_to_download = {i: url for i, url in enumerate(self._URLS)}
|
112 |
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
113 |
|
114 |
return [
|
115 |
datasets.SplitGenerator(
|
116 |
+
name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files[i]}
|
117 |
+
)
|
118 |
+
for i in urls_to_download.keys()
|
119 |
]
|
120 |
|
121 |
def _generate_examples(self, data_files):
|
122 |
+
key = 0
|
123 |
+
for name in data_files:
|
124 |
+
with gzip.open(name, "rb") as f:
|
125 |
for line in f.readlines():
|
126 |
yield key, {"text": line.decode("uft-8").strip()}
|
127 |
+
key += 1
|