Spaces:
Sleeping
Sleeping
Update backend/app.py
Browse files- backend/app.py +0 -3
backend/app.py
CHANGED
|
@@ -18,15 +18,12 @@ def static_files(filename):
|
|
| 18 |
violations = {} # session_id -> count
|
| 19 |
|
| 20 |
# Only the exact word "sex" (case-insensitive) is banned
|
| 21 |
-
# No other variants or keywords
|
| 22 |
EXACT_BAN_REGEX = re.compile(r"(^|\\b)sex(\\b|$)", re.IGNORECASE)
|
| 23 |
|
| 24 |
MAX_VIOLATIONS = 1 # immediate lockout after first exact match
|
| 25 |
|
| 26 |
def is_banned(text: str) -> bool:
|
| 27 |
# Only ban when the exact word "sex" appears as a token
|
| 28 |
-
# Examples banned: "sex", "Sex!", "the sex topic"
|
| 29 |
-
# Examples allowed: "sexton", "sexy" (per your request)
|
| 30 |
return bool(EXACT_BAN_REGEX.search(text))
|
| 31 |
|
| 32 |
@app.route("/moderate", methods=["POST"])
|
|
|
|
| 18 |
violations = {} # session_id -> count
|
| 19 |
|
| 20 |
# Only the exact word "sex" (case-insensitive) is banned
|
|
|
|
| 21 |
EXACT_BAN_REGEX = re.compile(r"(^|\\b)sex(\\b|$)", re.IGNORECASE)
|
| 22 |
|
| 23 |
MAX_VIOLATIONS = 1 # immediate lockout after first exact match
|
| 24 |
|
| 25 |
def is_banned(text: str) -> bool:
|
| 26 |
# Only ban when the exact word "sex" appears as a token
|
|
|
|
|
|
|
| 27 |
return bool(EXACT_BAN_REGEX.search(text))
|
| 28 |
|
| 29 |
@app.route("/moderate", methods=["POST"])
|