Spaces:
Sleeping
Sleeping
Download email_eval/preprocess.py from BrainDrive/Email-Eval: direct link, hf CLI and curl.
- Browser
- Download file 359 Bytes
-
https://huggingface.co/spaces/BrainDrive/Email-Eval/resolve/main/email_eval/preprocess.py
- Command line
-
hf download hf://spaces/BrainDrive/Email-Eval/email_eval/preprocess.py
-
curl -L -o preprocess.py https://huggingface.co/spaces/BrainDrive/Email-Eval/resolve/main/email_eval/preprocess.py
359 Bytes
| import regex as re | |
| WS = re.compile(r"\s+") | |
| SENT_SPLIT = re.compile(r"(?<=[.!?])\s+") | |
| def norm_text(s: str) -> str: | |
| return WS.sub(" ", (s or "").strip()) | |
| def word_count(s: str) -> int: | |
| if not s: return 0 | |
| return len(re.findall(r"\b[\p{L}\p{N}’']+\b", s)) | |
| def sentences(s: str): | |
| s = norm_text(s) | |
| return SENT_SPLIT.split(s) if s else [] | |