Update openwebtext_split.py
Browse files- openwebtext_split.py +5 -4
openwebtext_split.py
CHANGED
@@ -19,7 +19,7 @@ import os
|
|
19 |
import re
|
20 |
from itertools import chain
|
21 |
import tarfile
|
22 |
-
import
|
23 |
|
24 |
import datasets
|
25 |
|
@@ -40,6 +40,7 @@ An open-source replication of the WebText dataset from OpenAI.
|
|
40 |
_URL = "https://zenodo.org/record/3834942/files/openwebtext.tar.xz"
|
41 |
|
42 |
def custom_iter_archive(path_or_buf, _filter=lambda x: True):
|
|
|
43 |
def _iter_archive(f):
|
44 |
stream = tarfile.open(fileobj=f, mode="r|*")
|
45 |
for i, tarinfo in enumerate(stream):
|
@@ -56,10 +57,10 @@ def custom_iter_archive(path_or_buf, _filter=lambda x: True):
|
|
56 |
if not file_path.endswith('xz'):
|
57 |
continue
|
58 |
file_obj = stream.extractfile(tarinfo)
|
59 |
-
|
|
|
60 |
for j, xzinfo in enumerate(file_obj):
|
61 |
-
|
62 |
-
yield f
|
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 |
|
|
|
40 |
_URL = "https://zenodo.org/record/3834942/files/openwebtext.tar.xz"
|
41 |
|
42 |
def custom_iter_archive(path_or_buf, _filter=lambda x: True):
|
43 |
+
decompressor = lzma.LZMADecompressor()
|
44 |
def _iter_archive(f):
|
45 |
stream = tarfile.open(fileobj=f, mode="r|*")
|
46 |
for i, tarinfo in enumerate(stream):
|
|
|
57 |
if not file_path.endswith('xz'):
|
58 |
continue
|
59 |
file_obj = stream.extractfile(tarinfo)
|
60 |
+
decompressed_file = decompressor.decompress(file_obj)
|
61 |
+
print(type(decompressed_file))
|
62 |
for j, xzinfo in enumerate(file_obj):
|
63 |
+
yield j
|
|
|
64 |
stream.members = []
|
65 |
del stream
|
66 |
if hasattr(path_or_buf, "read"):
|