mIRC Home    About    Download    Register    News    Help

Print Thread
#38069 23/07/03 05:15 PM
Joined: Mar 2003
Posts: 63
N
NiCk2 Offline OP
Babel fish
OP Offline
Babel fish
N
Joined: Mar 2003
Posts: 63
Hi, I'm doing my script and it must detect bad words. This is how it works : for every subject (adverts, sex, bad language, etc) I have 2 lists. The first one is a list of exceptions and the second is a list of words to detect. For example in sex.ini you might have :

[Exceptions]
*sexy*=on
*red*hot*=on

[Words]
*sex*=on
*hot*=on

For each line said on a channel, it goes through the first list and if it doesn't finds any matching mask, goes through the second list. If ever it finds something there, it will call me.
But due to the big number of lists and of words in them, I takes a lot of time.
I was wondering how I could reduce that time with the .ini files or if it was probably better to use hash tables, not yet knowing how to use them.
Could you guide me by either giving me a better way to go through my .ini lists or how to use the hash tables ?
Thank you in advance for any help smile

#38070 23/07/03 06:43 PM
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
if you are looking for EXACT matches only, using ini files is overkill. Hash tables can be used, but if it's only to find an exact match, you could also use something simpler:

Code:
if ($istok(word1.word2.word3.word4.word5.word6.word7,badword,1,46)) { do stuff }


or set the word1.word2.word3.word4.word5.word6.word7 in a variable and use

Code:
if ($istok(%variable,badword,1,46)) { do stuff }


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
#38071 23/07/03 07:16 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Pasmal's Hash Table Swear Kicker apparently is exactly what you need. Read it carefully; if you don't get it at first, read it again. I'm sure you'll agree it's useful once you get the hang of it. One thing, instead of
$hmatch(swear_words,$strip($1-))
use
$hfind(swear_words,$strip($1-),1,W)
$hfind() is the 'modern' version of $hmatch(). $hmatch still works, but nobody knows for how long.

In your case, two hash tables, one for the words list and one for the exceptions list would probably do the job. You could add items like
/hadd exception *hot*sex* on
and
/hadd words *sex* on


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#38072 24/07/03 04:09 AM
Joined: Dec 2002
Posts: 87
Babel fish
Offline
Babel fish
Joined: Dec 2002
Posts: 87
I would consider using something like:

* hot *=on

Because, if a user uses "shot", it will get detected. Just make sure to include spaces to find EXACT word matches in sentences.


-Zmodem
#38073 24/07/03 11:28 AM
Joined: Mar 2003
Posts: 63
N
NiCk2 Offline OP
Babel fish
OP Offline
Babel fish
N
Joined: Mar 2003
Posts: 63
How can I put * hot * in that place ?
writeini sex.ini Words * hot * on
That will do this :
[Words]
*=hot
Maybe I should put :
[Words]
n0=* hot *
Thank you all for your help, I'll have a look at the hash tables, looks interesting smile


Link Copied to Clipboard