Update openwebtext_split.py
Browse files- openwebtext_split.py +7 -5
openwebtext_split.py
CHANGED
|
@@ -19,6 +19,7 @@ import os
|
|
| 19 |
import re
|
| 20 |
from itertools import chain
|
| 21 |
import tarfile
|
|
|
|
| 22 |
|
| 23 |
import datasets
|
| 24 |
|
|
@@ -55,11 +56,12 @@ def custom_iter_archive(path_or_buf, _filter=lambda x: True):
|
|
| 55 |
if not file_path.endswith('xz'):
|
| 56 |
continue
|
| 57 |
file_obj = stream.extractfile(tarinfo)
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
| 63 |
stream.members = []
|
| 64 |
del stream
|
| 65 |
if hasattr(path_or_buf, "read"):
|
|
|
|
| 19 |
import re
|
| 20 |
from itertools import chain
|
| 21 |
import tarfile
|
| 22 |
+
import lzma
|
| 23 |
|
| 24 |
import datasets
|
| 25 |
|
|
|
|
| 56 |
if not file_path.endswith('xz'):
|
| 57 |
continue
|
| 58 |
file_obj = stream.extractfile(tarinfo)
|
| 59 |
+
with lzma.LZMAFile(file_obj) as inner_stream:
|
| 60 |
+
for j, xzinfo in enumerate(inner_stream):
|
| 61 |
+
print(j, xzinfo)
|
| 62 |
+
if not xzinfo.name.endswith('txt'):
|
| 63 |
+
continue
|
| 64 |
+
yield xzinfo.name, inner_stream.extractfile(xzinfo)
|
| 65 |
stream.members = []
|
| 66 |
del stream
|
| 67 |
if hasattr(path_or_buf, "read"):
|