cc / .save /100k_sampling.py
binhvq's picture
HR-02 submit 83c28bf38d1e2785768a0981cd460525,e6c0a9e5897c7fdb07791b90530fabb7,ed57f3d8cd1d29286aeb2eeef91c0a98,81faf8ebf3735fe3d1acb98ca5a35617,ef55ac22144c718f4cbdd03e3fd57e09 (#78531)
d74eab0
raw
history blame
554 Bytes
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