on *:start: {
hmake WordList 500
if ($isfile(wordlist.hsh)) { hload WordList Wordlist.hsh }
}
on *:text:*:#: {
; Make sure there is a hash table and that all data is loaded.
if (!$hget(WordList)) {
hmake WordList 500
if ($isfile(wordlist.hsh)) { hload WordList Wordlist.hsh }
}
; Display word usage
if ($left($1,8) == !wcount-) {
var %word = $gettok($1,2,45)
var %times = $iif($hget(WordList,%word),$v1,0)
msg $chan %word was used %times $iif(%times == 1,time.,times.)
return
}
; Remove all punctuation and characters that are likely to be touching the words so something like "this." is treated as "this" . Add any others you think are needed.
var %cleaned.text = $replace($1-,.,$chr(32),?,$chr(32),!,$chr(32),-,$chr(32),_,$chr(32),$chr(42),$chr(32),",$chr(32),*,$chr(32))
var %cnt = 1
var %words = $gettok(%cleaned.text,0,32)
while (%cnt <= %words) {
hinc WordList $gettok(%cleaned.text,%cnt,32)
inc %cnt
}
hsave WordList Wordlist.hsh
}