"""Keep posts that talk about bots/fake accounts AND likes/follows/engagement on the poster's own content.""" import json, re d = json.load(open("posts.json", encoding="utf-8")) BOT = re.compile(r"\b(bots?|botted|fake (accounts?|engagement|likes|followers)|spam ?(accounts?|likes)|like ?farms?|auto-?lik\w*|mass[- ]lik\w*)\b", re.I) ENG = re.compile(r"\b(lik(e|es|ed|ing)|follow(s|ed|ers?|ing)?|repost\w*|engagement|boost\w*|notifications?)\b", re.I) MINE = re.compile(r"\b(my|me|i|i'm|i've|our|we)\b", re.I) NEAR = re.compile(r"(bots?|fake|spam|farm|auto-?lik\w*|mass[- ]lik\w*)\W+(?:\w+\W+){0,4}?(lik\w*|follow\w*|repost\w*|engag\w*)|(lik\w*|follow\w*|repost\w*|engag\w*)\W+(?:\w+\W+){0,4}?(bots?|fake|spam)", re.I) c = [p for p in d["posts"] if NEAR.search(p["text"]) and MINE.search(p["text"]) and not p["bot"]] c.sort(key=lambda p: p["time"]) json.dump(c, open("candidates.json", "w", encoding="utf-8"), ensure_ascii=False, indent=1) with open("cand.txt", "w", encoding="utf-8") as f: for i, p in enumerate(c): f.write(f"[{i}] {p['handle']} {p['time'][:16]} r={p['is_reply']} L{p['likes']}\n{p['text'].replace(chr(10),' ')[:400]}\n\n") print(len(d["posts"]), "->", len(c))