Update wikipedia-for-mask-filling.py
Browse files- wikipedia-for-mask-filling.py +15 -15
wikipedia-for-mask-filling.py
CHANGED
@@ -117,18 +117,18 @@ class WikipediaForMaskFilling(datasets.GeneratorBasedBuilder):
|
|
117 |
print(filepath)
|
118 |
if filepath:
|
119 |
logger.info("Generating examples from = %s", filepath)
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
|
|
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)
|