Download filter.py from unixdevil/social-media-post: direct link, hf CLI and curl.
- Browser
- Download file 522 Bytes
-
https://huggingface.co/datasets/unixdevil/social-media-post/resolve/main/filter.py
- Command line
-
hf download hf://datasets/unixdevil/social-media-post/filter.py
-
curl -L -o filter.py https://huggingface.co/datasets/unixdevil/social-media-post/resolve/main/filter.py
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") | |