Spaces:
Sleeping
Sleeping
File size: 760 Bytes
5f2a5b3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
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
|