mIRC Homepage
Posted By: NiCk2 Hash tables - 23/07/03 05:15 PM
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
Posted By: LocutusofBorg Re: Hash tables - 23/07/03 06:43 PM
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 }
Posted By: qwerty Re: Hash tables - 23/07/03 07:16 PM
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
Posted By: Zmodem Re: Hash tables - 24/07/03 04:09 AM
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.
Posted By: NiCk2 Re: Hash tables - 24/07/03 11:28 AM
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
© mIRC Discussion Forums