Spaces:
Sleeping
Sleeping
Download src/scraping/textutil.py from tktm8/EmpathemeBot_dev: direct link, hf CLI and curl.
- Browser
- Download file 336 Bytes
-
https://huggingface.co/spaces/tktm8/EmpathemeBot_dev/resolve/main/src/scraping/textutil.py
- Command line
-
hf download hf://spaces/tktm8/EmpathemeBot_dev/src/scraping/textutil.py
-
curl -L -o textutil.py https://huggingface.co/spaces/tktm8/EmpathemeBot_dev/resolve/main/src/scraping/textutil.py
336 Bytes
| def compact_blank_lines(text: str) -> str: | |
| lines = [line.rstrip() for line in text.splitlines()] | |
| out, prev_blank = [], False | |
| for ln in lines: | |
| blank = (ln.strip() == "") | |
| if blank and prev_blank: | |
| continue | |
| out.append("" if blank else ln) | |
| prev_blank = blank | |
| return "\n".join(out) | |