spell checker - 28/08/05 12:18 AM
Hey. I had a look at a spell checker made by Tat here. and I liked the idea. However, insted of correcting everyone unvolentarily, i wanted to make it work with a triiger like !spell WORD. If WORD was spelled correctly it would say so, if not, it would say it wasnt then show the suggestion. I am almost there. It will alert you if it's spelled wrong, but I cant get it to say if it's correct without flooding. Have a look:
Obviously all references of WORD would replaced by the word they are checking. As you can see, the line in red will flood if the word was spelled correctly. So how can this be corrected?
Thanks,
Austin
Code:
on *:TEXT:!spell*:#:{ set %spell.chan $chan check.spelling $2- } alias check.spelling { if ($1 == !help) { .timer 1 0 msg $chan !ignore <ignoreword>, !coff, !con, !nocorrect, !correct | return } if ($1 == !ignore) { write ignore.txt $2 | .timer 1 0 msg $chan the word " $+ $2 $+ " will be ignored from now on. | return } if ($1 == !coff) { %nocorrect = $true | .timer 1 0 msg $chan Correct Bot Off. | return } if ($1 == !con) { unset %nocorrect | .timer 1 0 msg $chan Correct Bot On. | return } if ((%nocorrect) || ($1- != $strip($1-))) { return } if ($1 == !nocorrect) { %donotcorrect = %donotcorrect $nick | .timer 1 0 msg $chan You won't be corrected. | return } if ($1 == !correct) { %donotcorrect = $remove(%donotcorrect,$nick) | .timer 1 0 msg $chan You will now be corrected. | return } if ($nick isin %donotcorrect) { return } var %sents = $remove($strip($1-),.,?,:,;,",*,&,^,%,$,#,@,!,'s,'ll,'ve",1,2,3,4,5,6,7,8,9,0,+,_,/,\,$chr(44)), %i = $numtok(%sents,32) var %sents = $replace(%sents,-,$chr(32)) while (%i >= 1) { if (!$read(ignore.txt, s, $gettok(%sents,%i,32))) do.check.word $gettok(%sents,%i,32) dec %i } } alias word.site { return http://dictionary.reference.com/search?q= $+ $1 } alias httpparse { if ($regex($1-, http:\/\/(?:(?:[^:]+)(?::(?:.+))?@)?([^/]*)(\/.*) )) { if ($prop == site) return $regml(1) if ($prop == file) return $regml(2) } } alias do.check.word { var %spelling.sock = spelling. $+ $1 if ($sock(%spelling.sock)) { return } sockopen %spelling.sock $httpparse($word.site($1)).site 80 sockmark %spelling.sock $word.site($1) } on *:SOCKOPEN:spelling.*: { if ($sock($sockname)) { sockwrite -n $sockname GET $httpparse($sock($sockname).mark).file HTTP/1.1 sockwrite -n $sockname Host: $httpparse($sock($sockname).mark).site sockwrite -n $sockname Connection: Keep-Alive sockwrite -n $sockname $crlf } } on *:SOCKREAD:spelling.*: { var %d, %link, %info sockread %d if (%d == $null) { [color:red]msg %spell.chan WORD is spelled Correctly.[/color] } if (<td><h2 style="margin-bottom: 2em;">* entr* found for <i>*</i>.</h2> iswm %d) { } if (<p>Did you mean <a href="*">*</a>?</p>* iswm %d) if ($regex(%d,/Did\syou\smean\s\<a[^\>]*\>([^\<]*)\<\/a\>/)) msg %spell.chan " $+ $remove($sockname,spelling.) $+ " is not a word. Did you mean: $regml(1) $+ ? }
Thanks,
Austin