471,353 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,353 software developers and data experts.

Function to filter cursed words

Hi,

I was asked to create a function to detect cursed words in user's input and
reject user's input if found, does anybody know existing codes I can use?

TIA
Jan 24 '06 #1
5 1598
Try this - very effective algorithm to detect words in text
http://www.codeproject.com/useritems/ahocorasick.asp

"John" <so*****@microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

I was asked to create a function to detect cursed words in user's input
and reject user's input if found, does anybody know existing codes I can
use?

TIA

Jan 24 '06 #2
Well, the way I do input masking for TextBoxes in a C# app is to use
the KeyPress event. This will be a little more difficult to catch
entire words. Basically, if we have.

TextBox someText = new TextBox();
someText.KeyPress += new KeyPressEventHandler(keyPressFunc);
private void keyPressFunc(object sender, KeyPressEventArgs e)
{
//here you can get the key that was pressed through e.KeyChar and
if you don't want that character to get processed
//use the following line of code

e.Handled = true;

//this will keep the textBox from processing the keystroke
}

This is how I keep users from doing things like entering text into
number only fields. It would take some modification to store key
strokes and compare them to a library of curse words. I hope this helps.

Jan 24 '06 #3
On Tue, 24 Jan 2006 13:19:58 -0800, "John" <so*****@microsoft.com>
wrote:
Hi,

I was asked to create a function to detect cursed words in user's input and
reject user's input if found, does anybody know existing codes I can use?

TIA

Be careful to look carefully at *exactly* how the filter works. There
is a town in England called Scunthorpe whose residents are all to
aware of the effect of sloppily programmed filters. That is not the
only example, but it does illustrate a real problem.

rossum
--

The ultimate truth is that there is no ultimate truth
Jan 24 '06 #4
Yes, and let us not forget the town of Penistone, either.

I've read that even Google's child-safe content filtering technology
does dumb stuff like this. It's not as easy as it looks to get it right.

--Bob

rossum wrote:
Be careful to look carefully at *exactly* how the filter works. There
is a town in England called Scunthorpe whose residents are all to
aware of the effect of sloppily programmed filters. That is not the
only example, but it does illustrate a real problem.

rossum

Jan 28 '06 #5
And even if correctly implemented it can usually be easily side stepped by
somebody determined to cause offence - symbols, deliberate typos (french
connection UK for instance), additional spacing, etc - all of which can
leave the intent (and offence) without any cursed words...

Marc
Jan 30 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Nathan Bloomfield | last post: by
4 posts views Thread by Thomas | last post: by
5 posts views Thread by Andy | last post: by
3 posts views Thread by bay_dar | last post: by
2 posts views Thread by ChianHsieh | last post: by
2 posts views Thread by amir | last post: by
3 posts views Thread by Mr 200 | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.