Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Censure Forbeiden Words

Status
Not open for further replies.

hackoo

Programmer
Jan 31, 2003
28
TN
Hello, I like to make a script running in loop like this.
The Aim of this one is to close any active application detecting Forbeiden words like "sex,sexe,porno,etc..."

'---------------------------------------Censure.vbs---------------------------------------
dim variable
Set variable=CreateObject("WScript.Shell")
do
if variable.AppActivate ("sexe") Then variable.SendKeys "%{F4}"
if variable.AppActivate ("sex") Then variable.SendKeys "%{F4}"
if variable.AppActivate ("porno") Then variable.SendKeys "%{F4}"
if variable.AppActivate ("baise") Then variable.SendKeys "%{F4}"
loop
 
Put your key words into a dictionary object. Then you can easily check to see if the key exists.

Code:
Dim oDic
Set oDic = CreateObject("scripting.dictionary")
intCount = 0
oDic.Add "porn", 1
TextToCheck = "Hey man did you check out that new porn posted?"

CensureArray = Split(TextToCheck," ")
For Each word In CensureArray 
	If oDic.Exists(word) Then
		intCount = intCount + 1
	End If
Next

If intCount > 0 Then
	WScript.Echo "Bad words found:" & intCount
Else
	WScript.Echo "Snow White!"
End If

The problem you will run into is that this method won't be 100% accurate. For example if the word "porn" was followed by punctuation the word changes to "porn?" and that would not equal "porn", same difference between "porn" and "porno".

You might try using regular expressions to check instead.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Hi Mark,

With RegEx, you'd probably need an 'allowed' dictionary also, for words like 'Essex' (the name of a town).

I think hackoo will also run into trouble where the word is an acceptable one in a different language and the string being tested is an expression in that language.


Cheers
[MS MVP - Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top