3

Possible Duplicate:
How do you implement a good profanity filter?

I have to take a city name from users as input, but I don't want to accept any profanities. Can anyone tell me how I can keep users from typing such words?

Community
  • 1
  • 1
Lokesh Paunikar
  • 1,679
  • 5
  • 21
  • 26
  • 5
    Also consider what you're going to do about the "Scunthorpe Problem": http://en.wikipedia.org/wiki/Scunthorpe_problem – Dafydd Rees Apr 29 '11 at 10:38

2 Answers2

3

You'd have to scan the input for all vulgarity, either post-entry or during the entry, and reject the content then. Inversoft (http://www.inversoft.com/) has a web service available that can help; you can also do a google search for "java profanity filter" to find other similar products.

Joseph Ottinger
  • 4,911
  • 1
  • 22
  • 23
  • 1
    Apparently Inversoft only began offering an API in July of 2015. Before that, it was just on-site software you had to install on your server. I recommend WebPurify for their API profanity filter; they've offered an API since 2006. They're constantly improving and upgrading their algorithms, so it just gets better over time: http://www.webpurify.com – Marshall Æon Oct 07 '15 at 03:32
1
  1. Define a list of profanities.
  2. Ask the user for input.
  3. Check the input. If it is equal to any item in your list of profanities, reject it.

Of course users will not be able to enter names of actual cities which are also profanities. By definition, you are excluding such cities.

Daniel Daranas
  • 22,454
  • 9
  • 63
  • 116