Spaces:
Running on Zero
Running on Zero
Download common.py from smshaqib/Wikipedia_AI_Content_Detection: direct link, hf CLI and curl.
- Browser
- Download file 472 Bytes
-
https://huggingface.co/spaces/smshaqib/Wikipedia_AI_Content_Detection/resolve/main/common.py
- Command line
-
hf download hf://spaces/smshaqib/Wikipedia_AI_Content_Detection/common.py
-
curl -L -o common.py https://huggingface.co/spaces/smshaqib/Wikipedia_AI_Content_Detection/resolve/main/common.py
472 Bytes
| import re | |
| def clean_text(t): | |
| """Exact cleaning rule from the project notebook (keep in sync).""" | |
| lines = str(t).split("\n") | |
| while len(lines) > 1: | |
| last = lines[-1].strip() | |
| if last == "" or (len(last.split()) <= 4 and not re.search(r"[.!?\"')]$", last)): | |
| lines.pop() | |
| else: | |
| break | |
| t = " ".join(lines) | |
| t = re.sub(r"={2,}", " ", t) | |
| t = re.sub(r"[*#`|_]", " ", t) | |
| return re.sub(r"\s+", " ", t).strip() | |