Spaces:
Sleeping
Sleeping
Download text_processing/preprocessing_span.py from HunterNope/AutoCenzurer: direct link, hf CLI and curl.
- Browser
- Download file 760 Bytes
-
https://huggingface.co/spaces/HunterNope/AutoCenzurer/resolve/main/text_processing/preprocessing_span.py
- Command line
-
hf download hf://spaces/HunterNope/AutoCenzurer/text_processing/preprocessing_span.py
-
curl -L -o preprocessing_span.py https://huggingface.co/spaces/HunterNope/AutoCenzurer/resolve/main/text_processing/preprocessing_span.py
760 Bytes
| from static.config import LABEL_ORDER | |
| from abstraction.span_schema import SpanSchema | |
| def max_label(llm_label: str, min_allowed_label: str) -> str: | |
| return max(llm_label, min_allowed_label, key=lambda l: LABEL_ORDER[l]) | |
| def resolve_min_label( | |
| has_excessive_profanity: bool, | |
| has_slur: bool, | |
| has_targeted_insult: bool, | |
| explicit_violence: bool = False, | |
| mass_harm_endorsement: bool = False | |
| ) -> str: | |
| min_label = "NONE" | |
| if has_targeted_insult or has_slur or ( | |
| has_excessive_profanity | |
| ): | |
| min_label = "HATE_SPEECH_GENERAL" | |
| if mass_harm_endorsement: | |
| min_label = "EXTREMISM_PROMOTION" | |
| if explicit_violence: | |
| min_label = "HARASSMENT_OBSCENITY" | |
| return min_label | |