nurik040404 commited on
Commit
391be5b
1 Parent(s): b2ea236

Update mse.py

Browse files
Files changed (1) hide show
  1. mse.py +6 -7
mse.py CHANGED
@@ -110,12 +110,11 @@ class StackExchange(datasets.GeneratorBasedBuilder):
110
  # This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
111
  # The `key` is here for legacy reason (tfds) and is not important in itself.
112
 
113
- with open(filepath, encoding="utf-8") as f:
114
  dctx = zstandard.ZstdDecompressor()
115
- i = 0
116
- with dctx.stream_reader(f) as st:
117
- with io.TextIOWrapper(st) as text_st:
118
- while (line:=text_st.readline()) != '':
119
- data = json.loads(line)
120
- yield i, data
121
  i += 1
 
110
  # This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
111
  # The `key` is here for legacy reason (tfds) and is not important in itself.
112
 
113
+ with open(filepath, 'rb') as f:
114
  dctx = zstandard.ZstdDecompressor()
115
+ with dctx.stream_reader(f) as ds:
116
+ with io.TextIOWrapper(ds) as s:
117
+ i = 0
118
+ while s.readable():
119
+ yield i, json.loads(s.readline())
 
120
  i += 1