Download backend/utils/scoring.py from KaustavMP/JalGuard: direct link, hf CLI and curl.
- Browser
- Download file 352 Bytes
-
https://huggingface.co/spaces/KaustavMP/JalGuard/resolve/main/backend/utils/scoring.py
- Command line
-
hf download hf://spaces/KaustavMP/JalGuard/backend/utils/scoring.py
-
curl -L -o scoring.py https://huggingface.co/spaces/KaustavMP/JalGuard/resolve/main/backend/utils/scoring.py
352 Bytes
| from __future__ import annotations | |
| import math | |
| def clamp_score(raw: float) -> float: | |
| # Validator requires strictly between 0 and 1, not 0.0 or 1.0. | |
| try: | |
| value = float(raw) | |
| except (TypeError, ValueError): | |
| value = 0.0 | |
| if not math.isfinite(value): | |
| value = 0.0 | |
| return max(0.01, min(0.99, round(value, 4))) | |