• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Stop user from entering a bad word?

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to write a code that stops a user from enter a swear word. how can i do it?
 
Marshal
Posts: 25594
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need two things to start with: (1) A list of bad words which you want to prevent, and (2) a description of what it means to "enter" a bad word. You especially need (2) before you can continue with your design process.

Of course you don't have to produce a complete and absolute list of bad words to start with. You can always change the list -- which means your design has to include that ability.

And one of the issues associated with (2) is, for example: Suppose that "bum" was in your bad-words list. If the user enters the word "album", does that constitute entering a bad word?
 
Paul Clapham
Marshal
Posts: 25594
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And when you say you want to stop the user from entering one of those words: do you really mean that? Like, the keyboard should freeze after they type three of the four letters so they can't actually enter the fourth letter? Or do you want your code to react in some way after they have entered one of the words?
 
Saloon Keeper
Posts: 12008
257
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this for an assignment?

If not, I assure you there is absolutely no point in trying this. People will always find a creative way around it, and it will end up hurting well-meaning users more than it's worth.
 
olu idowu
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Is this for an assignment?

If not, I assure you there is absolutely no point in trying this. People will always find a creative way around it, and it will end up hurting well-meaning users more than it's worth.



It's part of an assignment
 
olu idowu
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:And when you say you want to stop the user from entering one of those words: do you really mean that? Like, the keyboard should freeze after they type three of the four letters so they can't actually enter the fourth letter? Or do you want your code to react in some way after they have entered one of the words?



my assignment says that my code should react in some way.
 
Paul Clapham
Marshal
Posts: 25594
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay. So do you have a plan to get started? Do you have specific questions about that plan?
 
Sheriff
Posts: 21949
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:And one of the issues associated with (2) is, for example: Suppose that "bum" was in your bad-words list. If the user enters the word "album", does that constitute entering a bad word?


You're referring to the infamous clbuttic mistake, right?
 
Marshal
Posts: 69411
276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that an l after the C? I thought it was an I at first.
I had some special training at UCLA once, and emailed home about some beer which was so strong I had to wash it down with something lighter. What Ruth read included, “waXX XX down...”
 
Bartender
Posts: 2585
124
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

olu idowu wrote:...
my assignment says that my code should react in some way.


Interesting assignment, what is your approach so far?
Let's say "Donkey" is a bad word. What variations do you plan to disallow?
Here's some that come to my mind:
  • DoNkEy (Mixed case)
  • d___o.n.k_e.y (Special characters)
  • DNKY (vowels missing)
  • ___Donkeey!! (extra characters)
  •  
    Paul Clapham
    Marshal
    Posts: 25594
    69
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Rob Spoor wrote:You're referring to the infamous clbuttic mistake, right?



    More generally, the Scunthorpe problem.
     
    Rancher
    Posts: 179
    15
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Also in real life applications, you need to consider that your users might speak multiple languages.

    For example on the French version of a forum I was on, you can swear all you want in French and it doesn't censor it. But it doesn't let you type the word "drapeau" (flag) because letters 2 through 5 are detected as a bad word.
     
    I was born with webbed fish toes. This tiny ad is my only friend:
    Try Free Java/.NET Libraries for Word Excel PowerPoint and PDF
    htttp://www.e-iceblue.com/free-apis.html
      Bookmark Topic Watch Topic
    • New Topic