mIRC Home    About    Download    Register    News    Help

Print Thread
#221307 13/05/10 11:59 PM
Joined: Apr 2007
Posts: 60
M
maconga Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: Apr 2007
Posts: 60
I make a lot of typo's and do not notice them.
I was wondering if its possible to have a script that see's my typo's and can replace them automatically as I type.
I would like to have 2-3 words done, and i can figure out the rest.

I type " dont "
Script correction " don't "


Last edited by maconga; 14/05/10 12:05 AM.
Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
Code:
on *:INPUT:#,?:{
  if (!$ctrlenter && /* !iswm $1) {
    var %wordMistakes = /\b(word1|word2|word3|...)\b/ig
    tokenize 32 $regsubex($1-,%wordmistakes,$fixword(\t))
    msg $active $1-
    halt
  }
}
alias fixword {
  if ($1- == word1) { return word1replacement }
  elseif ($1- == word2) { return word2replacement }
  elseif ($1- == word3) { return word3replacement }
  elseif ($1- == ...) { return ...replacement }
  else { return $1- }
}

how I would do it, anyways

Last edited by FroggieDaFrog; 14/05/10 12:15 AM.

I am SReject
My Stuff
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
I think I'd recommend a hash table if you plan to add a lot of words. If it's only a few, then an the above works fine.... except that you'd probably want $1 in the alias instead of $1- if you're using single words.

A quick way (and it might work better combining it with regex...

Code:
on *:input:*: {
  if (!$ctrlenter && !$inpaste && $left($1,1) != $readini(mirc.ini,text,commandchar)) {
    CreateSpelling
    var %text = $1-, %t = $numtok($1-,32)
    while (%t) {
      var %text = $iif($hget(Spelling,$gettok(%text,%t,32)),$replace(%text,$gettok(%text,%t,32),$v1),%text)
      dec %t
    }
    msg $active %text
    halt
  }
}

alias CreateSpelling {
  if (!$hget(Spelling)) {
    hmake Spelling 10
    if ($exists(Spelling.hsh)) { hload Spelling Spelling.hsh }
  }
}

menu * {
  Spelling
  .Load Spelling:CreateSpelling
  .Add Word:hadd Spelling $$?="Enter misspelled word" $$?="Enter correct spelling"
  .Remove Word:hdel Spelling $$?="Enter the misspelled word you want to remove"
}


Note that you may also want to throw in some checks for punctuation as this won't match "dont" if it has punctuation next to it (e.g. "dont!"). This was just a quick thing I put together to give a general idea of how it works. It lets you add as many words as you want to with just a right click menu without editing the script at all.


Invision Support
#Invision on irc.irchighway.net
Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
Quote:
except that you'd probably want $1 in the alias instead of $1-


the reason I used $1- was so he/she could take into account strings of words. He/She could use to it replace something like "I am" with "I'm"


I am SReject
My Stuff
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Ok. smile


Invision Support
#Invision on irc.irchighway.net
Joined: Apr 2007
Posts: 60
M
maconga Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: Apr 2007
Posts: 60
Riamus2,

once again, thanks for your script. i love it.
also, I do plan on slowly adding 1000-2000 words as I am a HORRIBLE at spelling.

i changed this
Quote:
var %text = $iif($hget(Spelling,$gettok(%text,%t,32)),$replace(%text,$gettok(%text,%t,32),$v1),%text)


into
Quote:
var %text = $iif($hget(Spelling,$gettok(%text,%t,32)),$puttok(%text,$v1,%t,32),%text)




changed this
Quote:
.Add Word:hadd Spelling $$?="Enter misspelled word" $$?="Enter correct spelling"
.Remove Word:hdel Spelling $$?="Enter the misspelled word you want to remove"



into this

Quote:
.Add Word:hadd Spelling $$?="Enter misspelled word" $$?="Enter correct spelling" | hsave Spelling Spelling.hsh
.Remove Word:hdel Spelling $$?="Enter the misspelled word you want to remove" | hsave Spelling Spelling.hsh




FroggieDaFrog,

thanks for that script, but I'm looking for something really easy ( no offense ) [quote][/quote]

Last edited by maconga; 14/05/10 03:41 AM.
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
It may be possible to do a socket script for this, which finds a website that does the spell checking for you and outputs it with the correct spelling. The best part is, you don't have to store a thing.

Joined: Apr 2007
Posts: 60
M
maconga Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: Apr 2007
Posts: 60
Tomao,

yeah may be, but I'm looking for something simple that i can add/remove and not have to rely on anything else.



also, This is the text replacement from Pidgin, a multi-protocol program, and it would be interesting to have something like this in a script ( if possible )




Last edited by maconga; 14/05/10 03:59 AM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yeah, I forgot to put the /hsaves in there. Oops. smile

That popup could be created using dialogs and "loading" the hash table data into the dialog listbox and then adding a bit more information to the hash table including the checkbox information. It really wouldn't take much effort other than taking time to create the dialog. The only change to what you currently have is to add the checkbox values when you use /hadd and then only use the first token when you're using $hget() to display the correct spelling. The other thing you'd need changed is if you want to replace multiple words (like it' snot). What I gave you doesn't handle multiple words as-is. You can $replace spaces with another character (something you don't expect to see in the channel(s) you visit) to make it work.

If you do want to use something like that, I'd recommend trying to set up the dialog yourself and see if you can get it working. That part should be fairly easy as dialogs are all basically the same. They just usually take a lot more time to set up. That's really the only "hard" thing about dialogs.

Then, if you have any issues with it, post what you have and we'll help out.


Invision Support
#Invision on irc.irchighway.net
Joined: Apr 2007
Posts: 60
M
maconga Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: Apr 2007
Posts: 60
So far the script has been flawless until I noticed when I do a
Quote:
/me
in a channel, the script does not correct any words I have. How can I fix this?

Code:
on *:input:*: {
  if (!$ctrlenter && !$inpaste && $left($1,1) != $readini(mirc.ini,text,commandchar)) {
    CreateSpelling
    var %text = $1-, %t = $numtok($1-,32)
    while (%t) {
      var %text = $iif($hget(Spelling,$gettok(%text,%t,32)),$puttok(%text,$v1,%t,32),%text)      
      dec %t
    }
    msg $active %text
    halt
  }
}

alias CreateSpelling {
  if (!$hget(Spelling)) {
    hmake Spelling 10
    if ($exists(Spelling.hsh)) { hload Spelling Spelling.hsh }
  }
}

menu * {
  Spelling
  .Load Spelling:CreateSpelling
  .Add Word:hadd Spelling $$?="Enter misspelled word" $$?="Enter correct spelling" | hsave Spelling Spelling.hsh
  .Remove Word:hdel Spelling $$?="Enter the misspelled word you want to remove" | hsave Spelling Spelling.hsh
}

Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
add:
Code:
alias me {
  var %text = $1-, %t = $numtok($1-,32)
  while (%t) {
    var %text = $iif($hget(Spelling,$gettok(%text,%t,32)),$puttok(%text,$v1,%t,32),%text)      
    dec %t
  }
  $iif($show,!me,!.me) %text
}


I am SReject
My Stuff
Joined: Apr 2007
Posts: 60
M
maconga Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: Apr 2007
Posts: 60
FroggieDaFrog,

Thank You so much, its working

Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
That's what this forum is for smile


I am SReject
My Stuff
Joined: Feb 2009
Posts: 133
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2009
Posts: 133
hi
you can put in a file .txt columns in the format:

dont don't

and the code will be some thing like this just an EG

Code:
on *:input:*:{
  if $left($1,1) != / {
    var %x 1
    while ($gettok($1-,%x,32)) var %v $v1,%t %t $iif($read(file.txt,s,%v),$v1,%x %x + 1
    msg $active %t
    haltdef
  }
}



WorldDMT
Joined: Apr 2007
Posts: 60
M
maconga Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: Apr 2007
Posts: 60
chacha,

Your script, how do I integrate it? Please bare with me, as I have absolutely no understanding of scripting.

Joined: Feb 2009
Posts: 133
C
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2009
Posts: 133
that was just an eg but if you realy need it ok

creates a file (NotePad) and named wdic.txt and write in it

word the defenition here
dont don't
isnt is not

now take this part and put it into remote

Code:
on *:input:*:{
  if $left($1,1) != / {
    var %x 1
    while ($gettok($1-,%x,32)) var %v $v1,%t %t $iif($read(wdic.txt,s,$(,$+(%,v))),$v1,$(,$+(%,v))),%x %x + 1
    msg $active %t
    haltdef
  }
}


WorldDMT
Joined: Apr 2007
Posts: 60
M
maconga Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: Apr 2007
Posts: 60
chacha,

It works now, I see what I was doing wrong. I was doing
Quote:
dont=don't
instead of
Quote:
dont don't


Once again, Many Thanks.


Link Copied to Clipboard