Spaces:
Running
Running
Download news/dedup.py from Success-dev/venthrive-api: direct link, hf CLI and curl.
- Browser
- Download file 569 Bytes
-
https://huggingface.co/spaces/Success-dev/venthrive-api/resolve/main/news/dedup.py
- Command line
-
hf download hf://spaces/Success-dev/venthrive-api/news/dedup.py
-
curl -L -o dedup.py https://huggingface.co/spaces/Success-dev/venthrive-api/resolve/main/news/dedup.py
569 Bytes
| """URL-hash dedup (ADR-0015: dedup runs before classification, so we never | |
| spend a Groq call on something we're about to discard as already-seen).""" | |
| import hashlib | |
| def url_hash(url: str) -> str: | |
| # Trailing slashes and query strings are common no-op variants of the same | |
| # article URL — strip them so the same piece of content doesn't get | |
| # rescraped as "new" on a second poll just because of a tracking param. | |
| normalized = url.strip().rstrip("/").split("?", 1)[0].split("#", 1)[0] | |
| return hashlib.sha256(normalized.encode("utf-8")).hexdigest() | |