Commit ·
391be5b
1
Parent(s): b2ea236
Update mse.py
Browse files
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,
|
| 114 |
dctx = zstandard.ZstdDecompressor()
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
while
|
| 119 |
-
|
| 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
|