SamanthaStorm commited on
Commit
012c587
·
verified ·
1 Parent(s): 4634a37

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -3
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
- primary_threats = {"insults", "control"}
349
- supporting_risks = {"gaslighting", "dismissiveness", "blame shifting"}
 
 
 
 
 
 
 
 
 
350
 
351
  has_primary = bool(primary_threats & pattern_set)
352
- has_supporting = bool(supporting_risks & pattern_set)
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"""