Very simple spell checker using basic sockets to spellcheck a word. $spellcheck()
; -------------------------------------
; $spellcheck()
; Spell checks a word based on data from www.spellchecker.net
; $spellcheck(<word>)
; -------------------------------------
alias spellcheck {
if ($1) && ($1 isalpha) {
set %spell.input $1
sockopen SPELLCHECKING www.spellcheck.net 80
return %spelling.output
}
var %e = .echo -ac info * $!spellcheck:
if (!$1) %e no parameters
elseif ($1 !isalpha) %e insufficient parameters
halt
}
on *:sockopen:SPELLCHECKING:{
unset %spell.output
sockwrite -nt SPELLCHECKING GET /cgi-bin/spell.exe?action=CHECKWORD&string= $+ %spell.input HTTP/1.0
sockwrite -n SPELLCHECKING
}
on *:sockread:SPELLCHECKING: {
var %t
sockread %t
if (*is misspelled* iswm $nohtml(%t)) {
set %spelling.output FALSE
.echo -q $spelling.output
sockclose SPELLCHECKING
halt
}
if (*spelled correctly* iswm $nohtml(%t)) {
set %spelling.output TRUE
sockclose SPELLCHECKING
}
}
on *:sockclose:SPELLCHECKING:unset %spell.input
alias nohtml {
var %o, %temp = $regsub($1-,/(<[^>]+>)/g,$null,%o)
return %o
}
Mountaindew, it doesn\'t look like that serves any purpose in this snippet, so I don\'t think is vital to the functionality. It wouldn\'t make sense to have it as %spelling.output because %spelling.output returns the results, and isn\'t an identifier. However, that line serves no purpose in the script so the author should remove it.
Rebellious, I\'ve noticed that your script doesn\'t return the results on cue. IE: if you used //echo -a $spellcheck(misspelled word) and then use //echo -a $spellcheck(correctly spelled word) again, they would return the same results. After much irritability and using the command multiple times with the same syntax, I\'ve also realized that the script will return the correct result if you were to use the second command again:
First round: //echo -a $spellcheck(assafaff) returns FALSE
Second round: //echo -a $spellcheck(hello) returns FALSE
Third round: //echo -a $spellcheck(hello) returns TRUE
~Tsuiseki
Now uses sockets.
Here is the COM version in case you care. Same syntax and all:
alias spellcheck {
if ($1) && ($1 isalpha) {
if (!$comerr) {
if ($com(spellcheck)) .comclose spellcheck
.comopen spellcheck Word.Application
.echo -q $com(spellcheck,CheckSpelling,1,string,$1)
return $com(spellcheck).result
}
}
var %e = .echo -ac info * $!spellcheck:
if (!$1) %e no parameters
elseif ($1 !isalpha) %e insufficient parameters
halt
}