KaraKaraWitch commited on
Commit
149cce2
1 Parent(s): b9bd58b

Upload scripts/guten2jsonl.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. scripts/guten2jsonl.py +19 -0
scripts/guten2jsonl.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pathlib
2
+
3
+ import orjson
4
+
5
+ with open("compiled.jsonl","wb") as f:
6
+ for file in pathlib.Path("data").iterdir():
7
+ if file.is_file():
8
+ pushback = ""
9
+ for line in file.read_text(encoding="utf-8").split("\n"):
10
+ if line == "":
11
+ pushback += "\n"
12
+ continue
13
+ if line == line.upper():
14
+ continue
15
+ else:
16
+ pushback += line + "\n"
17
+ pushback = pushback.strip()
18
+ # print(pushback.strip())
19
+ f.write(orjson.dumps({"text":pushback}) + b"\n")