?
Solved

Rude word filter

Posted on 2004-09-17
10
Medium Priority
?
412 Views
Last Modified: 2012-03-15
Hi ppl!

I need to add a rude word filter to a webform to check if a user has entered an obscene word in a sentence stored in a string captured from a textbox. Can someone recommend a way of doing this in c#. Also does anyone know a source/library of common rude words to use?

Thanks for your help,
Kevin
0
Comment
Question by:tnook
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 3

Expert Comment

by:ruff_ryder
ID: 12090328
This sounds like a classic parsing problem. Basically what you want to do is parse the text for your predefined rude words when the Textbox text is validating. I'll start you off by telling you to have a look at the Validating Events for the Textbox control and also the Regex class to help you with the parsing.

Do some reading on those and make an attempt at some code. If you have further problems then check back here and I'll try to help.
0
 
LVL 19

Expert Comment

by:Fahad Mukhtar
ID: 12090697
you can have an arraylist and then filll targat arraylist with all the common rude words...

if (RudeWords.Contains(InputWord)) //input word from user is being checked
 {
//word is catch!!
 }
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12091101
This link shows an example to do such things
http://www.codefixer.com/codesnippets/replacebadwords.asp
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 10

Accepted Solution

by:
ptmcomp earned 1600 total points
ID: 12091150
This could work similar to SPAM filters like K9. First parse the text and seperate words (e.g. using regex), then look them up in a hashtable/database.
0
 
LVL 7

Expert Comment

by:jackiechen858
ID: 12091334
I agree with ptmcomp's suggestion:

                  string Commend= "I love this game game";

                  string []words= Commend.Split(new Char[] {' '});
                  Hashtable ht = new Hashtable();
                  for ( int i=0;i< words.Length;i++)
                  {
                        if ( !ht.ContainsKey(words[i].ToLower()) )
                              ht.Add(words[i],words[i].ToLower());
                  }
                  ArrayList badwords = new ArrayList();
                  badwords.Add("bad");
                  bool bFind = false;
                  for ( int i=0;i<badwords.Count;i++)
                  {
                        if ( ht.ContainsKey(badwords[i]))
                        {
                              bFind=true;
                              break;
                        }
                  }


If the input is quite a long sentence, it will be more efficient than searching the whole string. But if the input is a different language which don't split words by space,  that's a different story.
0
 
LVL 6

Expert Comment

by:DominicCronin
ID: 12093144
Don't forget that a poor implementation will earn you the scorn of all the inhabitants of Scunthorpe and Penistone.
0
 
LVL 10

Expert Comment

by:smegghead
ID: 12102782
I know Scunthorpe is a place, and a football team, but is Penistone a place ?? never heard of that one.
0
 
LVL 6

Expert Comment

by:DominicCronin
ID: 12105228
Indeed Penistone is a place. I imagine they suffer just as badly as Scunthorpe in the Internet filtering game. Still - Scunthorpe is more famous, if only because of the ill-fated proposal to change the name to Sconthorpe for Internet use. Talk about get a life!
0
 
LVL 10

Expert Comment

by:smegghead
ID: 12105271
Then they'd have the trouble with whether to pronounce it Scone-Thorpe or Scon-Thorpe

Anyway... :-)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month14 days, 2 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question