Datasets:
Tasks:
Fill-Mask
Sub-tasks:
masked-language-modeling
Languages:
English
Size:
10M<n<100M
ArXiv:
License:
Add exception handling
Browse files- pile-of-law.py +15 -12
pile-of-law.py
CHANGED
@@ -255,15 +255,18 @@ class PileOfLaw(datasets.GeneratorBasedBuilder):
|
|
255 |
id_ = 0
|
256 |
for filepath in filepaths:
|
257 |
logger.info("generating examples from = %s", filepath)
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
|
|
|
|
|
|
|
255 |
id_ = 0
|
256 |
for filepath in filepaths:
|
257 |
logger.info("generating examples from = %s", filepath)
|
258 |
+
try:
|
259 |
+
with xz.open(open(filepath, "rb"), "rt", encoding="utf-8") as f:
|
260 |
+
for line in f:
|
261 |
+
if line:
|
262 |
+
example = json.loads(line)
|
263 |
+
if example is not None and isinstance(example, dict):
|
264 |
+
yield id_, {
|
265 |
+
"text": example.get("text", ""),
|
266 |
+
"created_timestamp": example.get("created_timestamp", ""),
|
267 |
+
"downloaded_timestamp": example.get("downloaded_timestamp", ""),
|
268 |
+
"url": example.get("url", "")
|
269 |
+
}
|
270 |
+
id_ += 1
|
271 |
+
except:
|
272 |
+
print("Error reading file:", filepath)
|