social-media-post / filter.py
Bogdanel Stefan
More
7a2d92d
Raw History Blame Contribute Delete
522 Bytes
INPUT = "augmented_dataset.jsonl"
OUTPUT = "clean_dataset.jsonl"
def is_valid(text):
if len(text) < 30:
return False
if len(text) > 500:
return False
if "lorem ipsum" in text.lower():
return False
return True
with open(INPUT) as f_in, open(OUTPUT, "w") as f_out:
for line in f_in:
row = json.loads(line)
last_msg = row["messages"][-1]["content"]
if is_valid(last_msg):
f_out.write(json.dumps(row) + "\n")
print("✅ Clean dataset ready")