Spaces:
Sleeping
Sleeping
Download ingestion_python/utils/service/common.py from khoaliamle/EdSummariser: direct link, hf CLI and curl.
- Browser
- Download file 543 Bytes
-
https://huggingface.co/spaces/khoaliamle/EdSummariser/resolve/main/ingestion_python/utils/service/common.py
- Command line
-
hf download hf://spaces/khoaliamle/EdSummariser/ingestion_python/utils/service/common.py
-
curl -L -o common.py https://huggingface.co/spaces/khoaliamle/EdSummariser/resolve/main/ingestion_python/utils/service/common.py
543 Bytes
| import re | |
| import unicodedata | |
| from utils.logger import get_logger | |
| logger = get_logger("COMMON", __name__) | |
| def split_sentences(text: str): | |
| return re.split(r"(?<=[\.\!\?])\s+", text.strip()) | |
| def slugify(value: str): | |
| value = str(value) | |
| value = unicodedata.normalize("NFKD", value).encode("ascii", "ignore").decode("ascii") | |
| value = re.sub(r"[^\w\s-]", "", value).strip().lower() | |
| return re.sub(r"[-\s]+", "-", value) | |
| def trim_text(s: str, n: int): | |
| s = s or "" | |
| if len(s) <= n: | |
| return s | |
| return s[:n] + "…" |