iimran commited on
Commit
32cfc9b
·
verified ·
1 Parent(s): 698b30e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -68,9 +68,15 @@ def get_banned_keywords():
68
  def contains_banned_keyword(self, text):
69
  """Check if the input text contains any banned keywords."""
70
  text_lower = text.lower()
 
 
 
 
71
  for keyword in self.banned_keywords:
72
- if keyword in text_lower:
73
- # Print which keyword was found (for debugging)
 
 
74
  print(f"Keyword detected: '{keyword}'")
75
  return True
76
 
 
68
  def contains_banned_keyword(self, text):
69
  """Check if the input text contains any banned keywords."""
70
  text_lower = text.lower()
71
+
72
+ # Split the text into words
73
+ words = ''.join(c if c.isalnum() else ' ' for c in text_lower).split()
74
+
75
  for keyword in self.banned_keywords:
76
+ keyword_lower = keyword.lower()
77
+
78
+ # Check if keyword is a whole word in the text
79
+ if keyword_lower in words:
80
  print(f"Keyword detected: '{keyword}'")
81
  return True
82