mIRC Home    About    Download    Register    News    Help

Print Thread
spell checker #128655 28/08/05 12:18 AM
Joined: Jun 2005
Posts: 127
H
HAMM3R Offline OP
Vogon poet
OP Offline
Vogon poet
H
Joined: Jun 2005
Posts: 127
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:
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) $+ ?
}
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


-- HAMM3R (aka: alhammer)
http://www.HAMM3R.net
Re: spell checker #128656 28/08/05 01:19 AM
Joined: Aug 2005
Posts: 1,052
L
Lpfix5 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Pay attention to the variables in this scenario and leave if (%d == $null) { msg %spell.chan WORD is spelled Correctly. } too... if (%d == $null) { Return }

you see in this script
if ($1 == !con) ... bot turns on because it sets a variable so before you type !con on your bot your script wont go no where smile

i know nothing about sock reads yet.......


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Re: spell checker #128657 28/08/05 03:46 AM
Joined: Jun 2005
Posts: 127
H
HAMM3R Offline OP
Vogon poet
OP Offline
Vogon poet
H
Joined: Jun 2005
Posts: 127
I know that if (%d == $null) should be be set to "return". But it's when %d == $null that the word specified was correctly spelled. So i need a way to message the channel when %d == $null.


-- HAMM3R (aka: alhammer)
http://www.HAMM3R.net
Re: spell checker #128658 28/08/05 04:27 AM
Joined: Aug 2005
Posts: 1,052
L
Lpfix5 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Quote:
I know that if (%d == $null) should be be set to "return". But it's when %d == $null that the word specified was correctly spelled. So i need a way to message the channel when %d == $null.


np add a break example return | newscript which is msg blah blah


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Re: spell checker #128659 28/08/05 05:48 AM
Joined: Jun 2005
Posts: 127
H
HAMM3R Offline OP
Vogon poet
OP Offline
Vogon poet
H
Joined: Jun 2005
Posts: 127
Well, here is what me and a friend were able to come up with:
Code:
on *:SOCKREAD:spelling.*: {
  var %d, %link, %info
  sockread %d
  if (%d == $null) { return }
  if (<h2 style="margin-bottom: 2em;">*entr*found for <i>*</i>.</h2> iswm %d) { 
    if ($gettok($gettok(%d,3,32),2,62) isnum) {
      msg %spell.chan $remove($sockname,spelling.) is correct 
    }
    elseif ($gettok($gettok(%d,3,32),2,62) == No) { msg %spell.chan $remove($sockname,spelling.) is incorrect }
  }
  if (<p>Did you mean <a href="*">*</a>?</p>* iswm %d) if ($regex(%d,/Did\syou\smean\s\<a[^\>]*\>([^\<]*)\<\/a\>/)) msg %spell.chan Did you mean: $regml(1) $+ ?
}
But does anyone know a way to get the "Did you mean: blah?" on the same line as "Blah is incorrect" ????


-- HAMM3R (aka: alhammer)
http://www.HAMM3R.net