Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -345,14 +345,28 @@ def detect_compound_threat(patterns):
|
|
345 |
"""Helper function to standardize threat detection logic"""
|
346 |
pattern_set = set(p.lower() for p in patterns)
|
347 |
|
348 |
-
|
349 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
350 |
|
351 |
has_primary = bool(primary_threats & pattern_set)
|
352 |
-
has_supporting =
|
353 |
|
|
|
|
|
|
|
|
|
354 |
return has_primary and has_supporting
|
355 |
|
|
|
356 |
@spaces.GPU
|
357 |
def compute_abuse_score(matched_scores, sentiment):
|
358 |
"""Compute abuse score from matched patterns and sentiment"""
|
|
|
345 |
"""Helper function to standardize threat detection logic"""
|
346 |
pattern_set = set(p.lower() for p in patterns)
|
347 |
|
348 |
+
# Expand primary threats to include more patterns
|
349 |
+
primary_threats = {"control", "insults", "blame shifting"}
|
350 |
+
|
351 |
+
# Expand supporting risks to include more patterns
|
352 |
+
supporting_risks = {
|
353 |
+
"gaslighting",
|
354 |
+
"dismissiveness",
|
355 |
+
"blame shifting",
|
356 |
+
"guilt tripping",
|
357 |
+
"contradictory statements"
|
358 |
+
}
|
359 |
|
360 |
has_primary = bool(primary_threats & pattern_set)
|
361 |
+
has_supporting = len(supporting_risks & pattern_set) >= 1 # Only need one supporting risk
|
362 |
|
363 |
+
# Additional check for control + any other pattern
|
364 |
+
if "control" in pattern_set and len(pattern_set) > 1:
|
365 |
+
return True
|
366 |
+
|
367 |
return has_primary and has_supporting
|
368 |
|
369 |
+
|
370 |
@spaces.GPU
|
371 |
def compute_abuse_score(matched_scores, sentiment):
|
372 |
"""Compute abuse score from matched patterns and sentiment"""
|