profanity.py 390 B

123456789101112131415
  1. from fastapi import APIRouter, Body, Depends, HTTPException
  2. from app.utils import DFAFilter, NaiveFilter
  3. router = APIRouter()
  4. @router.get("/")
  5. def profanity(text: str):
  6. "Return True if there are any profanity words"
  7. filter = NaiveFilter()
  8. filter.parse('/home/conrad/creator/bad_words.txt')
  9. if '*' in filter.filter(text):
  10. return True
  11. else:
  12. return False