File size: 554 Bytes
d74eab0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import glob, sys, gzip, random, json
dumps = glob.glob("CC-MAIN-*")
for dump in dumps:
print(dump)
buckets = glob.glob(f"{dump}/CC-MAIN-*")
for bucket in buckets:
bucket = bucket.replace(f"{dump}/", f"{dump}_")
bucket = bucket.replace("CC-MAIN-", "")
with gzip.open(f"jsonl/{bucket}.jsonl.gz") as fin:
count = 0
for line in fin:
if random.randint(0, 90) < 3:
count += 1
text = json.loads(line)["text"]
ss = json.dumps({ "text" : text }, ensure_ascii = False)
print(ss)
if count == 1000: break |