SSS
SSS

Reputation: 203

spam and dirty words comment post filtering/prevention/blocking in python (django)

My basic question is how to prevent spam and dirty words in a comment post system under python (django).

I have a collection of phrases (approximately 3000 phrases) to be blocked.

What I want to do is like this:

If I found a comment which has a dirty-word when user clicks the post button, then the web should popup a warning message and asked people to re-enter/correct the comments and submit it again. This is just preventing people to submit rude/spam comments.

Question (1), are there any existing open source python (or django) package/module/plugin which can handle this job? I knew there was one called Akismet. But from what I understood, it will not solve my problem. Akismet is just a web service and filter the words dictionary defined by Akismet. But I have my own collection of words. Please correct me if I am wrong.

Question (2), If there is no such open source package I can use, how to create my own one? The only thing I can think of it's to use regular expression and join all the word phrases with 'or' in a regular expression. but I have 3000 phrases, I think it won't work in term of performance and filter every comment post. any suggestions where should I start from?

Thank you very much for your help and time.

Upvotes: 1

Views: 2813

Answers (1)

imjoevasquez
imjoevasquez

Reputation: 14381

You may want to check out the PROFANITIES_LIST setting, looks like you can use it with validators.

Although, with that many (3000 really? you must be fun at parties) phrases you want to rethink things. You shouldn't filter SPAM. You should throw it away. Just my opinion. If the comment has SPAM in it, why keep it at all? Is there any value added from such a comment?

Upvotes: 4

Related Questions