File size: 916 Bytes
365cd4e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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()