Recursalberg / scripts /guten2jsonl.py
KaraKaraWitch's picture
Upload scripts/guten2jsonl.py with huggingface_hub
149cce2 verified
raw
history blame
612 Bytes
import pathlib
import orjson
with open("compiled.jsonl","wb") as f:
for file in pathlib.Path("data").iterdir():
if file.is_file():
pushback = ""
for line in file.read_text(encoding="utf-8").split("\n"):
if line == "":
pushback += "\n"
continue
if line == line.upper():
continue
else:
pushback += line + "\n"
pushback = pushback.strip()
# print(pushback.strip())
f.write(orjson.dumps({"text":pushback}) + b"\n")