SuperWiki-1.5 / Scripts /sv-robot.py
KaraKaraWitch's picture
Inital Commit
365cd4e
raw
history blame contribute delete
916 Bytes
import pathlib, typer, tqdm
import orjson, re
app = typer.Typer()
rgx = re.compile(r"\|Lsjbot\|")
@app.command()
def main(in_folder: pathlib.Path, output_file: pathlib.Path):
taints = 0
with open(output_file, "wb") as fout:
for file in pathlib.Path(in_folder).iterdir():
if file.is_file() and file.suffix.endswith(".jsonl"):
with open(file, "rb") as f:
for line in tqdm.tqdm(f):
data = orjson.loads(line)
if rgx.findall(data["wikitext"]):
# print("TAINT:", data["title"], "Appears to be a lsjbot article generated.")
taints += 1
else:
fout.write(line.rstrip())
fout.write(b"\n")
print(f"Tainted LSJBot: {taints} found.")
if __name__ == "__main__":
app()