Update wikipedia-for-mask-filling.py
Browse files- wikipedia-for-mask-filling.py +19 -15
wikipedia-for-mask-filling.py
CHANGED
@@ -105,26 +105,30 @@ class WikipediaForMaskFilling(datasets.GeneratorBasedBuilder):
|
|
105 |
def _split_generators(self, dl_manager):
|
106 |
type = self.config.type
|
107 |
size = self.config.size
|
108 |
-
|
109 |
-
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
110 |
|
111 |
return [
|
112 |
-
datasets.SplitGenerator(name='train', gen_kwargs={"filepath":
|
113 |
]
|
114 |
|
115 |
def _generate_examples(self, filepath):
|
116 |
_id = 0
|
117 |
print("using filepaths:")
|
118 |
print(filepath)
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
105 |
def _split_generators(self, dl_manager):
|
106 |
type = self.config.type
|
107 |
size = self.config.size
|
108 |
+
filepath = dl_manager.download(f"data/{type}_{size}.jsonl.xz")
|
|
|
109 |
|
110 |
return [
|
111 |
+
datasets.SplitGenerator(name='train', gen_kwargs={"filepath": filepath}),
|
112 |
]
|
113 |
|
114 |
def _generate_examples(self, filepath):
|
115 |
_id = 0
|
116 |
print("using filepaths:")
|
117 |
print(filepath)
|
118 |
+
if filepath:
|
119 |
+
logger.info("Generating examples from = %s", filepath)
|
120 |
+
try:
|
121 |
+
with xz.open(open(filepath,'rb'), 'rt', encoding='utf-8') as f:
|
122 |
+
json_list = list(f)
|
123 |
+
|
124 |
+
for json_str in json_list:
|
125 |
+
example = json.loads(json_str)
|
126 |
+
if example is not None and isinstance(example, dict):
|
127 |
+
yield id_, {
|
128 |
+
"texts": data["texts"],
|
129 |
+
"masks": data["masks"]
|
130 |
+
}
|
131 |
+
id_ +=1
|
132 |
+
|
133 |
+
except Exception:
|
134 |
+
logger.exception("Error while processing file %s", filepath)
|