Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
| 73 |
-
|
|
|
|
|
|
|
| 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 |
|