nthngdy commited on
Commit
f8f2576
1 Parent(s): db5cf33

Update openwebtext_split.py

Browse files
Files changed (1) hide show
  1. openwebtext_split.py +5 -6
openwebtext_split.py CHANGED
@@ -54,10 +54,7 @@ def custom_iter_archive(path_or_buf, _filter=lambda x: True):
54
  if not file_path.endswith('xz'):
55
  continue
56
  file_obj = stream.extractfile(tarinfo)
57
- print(file_obj)
58
- for txt_file in file_obj:
59
- if txt_file:
60
- yield file_path, file_obj
61
  stream.members = []
62
  del stream
63
  if hasattr(path_or_buf, "read"):
@@ -97,8 +94,10 @@ class Openwebtext(datasets.GeneratorBasedBuilder):
97
  datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"files": custom_iter_archive(archive, test_filter)}),
98
  ]
99
 
100
- def _generate_examples(self, txt_files):
101
  """Yields examples."""
102
- for idx, filepath in enumerate(txt_files):
 
 
103
  with open(filepath, encoding="utf-8") as f:
104
  yield idx, {"text": re.sub("\n\n\n+", "\n\n", f.read()).strip()}
 
54
  if not file_path.endswith('xz'):
55
  continue
56
  file_obj = stream.extractfile(tarinfo)
57
+ yield file_path, file_obj
 
 
 
58
  stream.members = []
59
  del stream
60
  if hasattr(path_or_buf, "read"):
 
94
  datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"files": custom_iter_archive(archive, test_filter)}),
95
  ]
96
 
97
+ def _generate_examples(self, files):
98
  """Yields examples."""
99
+ for idx, filepath in enumerate(files):
100
+ if not filepath.endswith('txt'):
101
+ continue
102
  with open(filepath, encoding="utf-8") as f:
103
  yield idx, {"text": re.sub("\n\n\n+", "\n\n", f.read()).strip()}