Shoutbox

Slang Replacer - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Slang Replacer (/showthread.php?tid=63357)

Slang Replacer by stuartbennett on 07-16-2006 at 09:11 AM

i tryed slang replacer today and found a minor glitch with it for example typing the word "Breakfast" results in "Best Regardseakfast" its only a few minor things like that if someone can program some logic into it so it know when something is slang and when something is part of a proper word thatd be cool.


RE: Slang Replacer by fish-luke on 07-16-2006 at 04:45 PM

well that script is designed to do that, however it doesn't work for other slang words eg BRB. I guess that if it bothers you too much, you will just have to delete the script...:S


RE: Slang Replacer by 4penguino on 07-16-2006 at 04:49 PM

there are many glitches im=instant message and bro=bestreguardso its br which stands 4 best reguardso or summat like that and 2 get around that u have 2 put Bro or I'm its very um............confused


RE: Slang Replacer by stuartbennett on 07-16-2006 at 05:19 PM

isnt there a way to tell the program that if say a letter is directly after the supposid slang then its a word but if its a space after the slang then translate it? i can understand that im=instant message and i dont mind having to type it gramatically correct "i'm" but breakfast being translated wrongly just seems stupid. i have stopped the svript from running for now but would hope the glitch is fixable maybe not immediately but eventually.


RE: Slang Replacer by Keikonium on 07-16-2006 at 06:16 PM

Most people have semi good grammar, so this should be a nice little fix. When you type, you usually use spaces. Ex:

Bob says:
Hey John, I g2g, hospital time... :(
---> Hey John, I got to go, hospital time... :(

John says:
Okay, br buddy :)
---> Okay, best reguards buddy :)

So, a simple fix would be instead of:

sMessage = sMessage.replace(/br/gi,"best reguards");
make it
sMessage = sMessage.replace(/ br /gi," best reguards ");

:). Notice the space. This wont catch "br" at the end of a sentance however. But if you put an extra space at the end, it'll catch it ;).

This is how I wrote my personal script anyway.


RE: Slang Replacer by segosa on 07-16-2006 at 09:57 PM

Split the input message by a space and loop through each element. Check each element in turn to see if it matches a pre-defined list of known 'slang' words. (For bonus points strip punctuation out of it and preserve it later on!) If it does, replace that array element with a replacement (figure out an associative array or somesuch for it, else use a txt file, far better). Join the array back together by spaces and send it.


RE: Slang Replacer by Ezra on 07-16-2006 at 10:20 PM

quote:
Originally posted by Keikonium
So, a simple fix would be instead of:
code:
sMessage = sMessage.replace(/br/gi,"best reguards");
make it
sMessage = sMessage.replace(/ br /gi," best reguards ");



I think this would be even better:
code:
/(^|\s+)br($|\s+)/igm

And indeed use segosa's idea for the checking method
RE: Slang Replacer by Silentdragon on 07-16-2006 at 11:11 PM

Hmm wouldn't this be better?

code:
/\bbr\b/mgi

Doesn't need to check if its at the begining or not or space character as it looks for word boundries, And works with punctuation. Plus it doesn't chop out the space.

Also the writer should have did a spell check. Regards is not spelled reguards.
RE: Slang Replacer by Keikonium on 07-16-2006 at 11:45 PM

Wow, your methods look so much better than mine did, and it looks to work like mine doesn't :D.

May I ask a question... The /*letter*.. I only know of:

/i = doesn't look for uppser/lowercase?
/g = no idea... found it in some code :S.

What are all the /*letters* that you can use, and what do they do. I looked thru the documentation breifly, but didn't see anything about this (probably missed it).

And what are the $, +, and | for :S? Is there a place that can tell me all this. Sorry to be such a noob :$ lol.


RE: Slang Replacer by cooldude_i06 on 07-16-2006 at 11:50 PM

They are called regular expressions. Here is more info:
http://authors.aspalliance.com/wsk/aboutregularexpression.asp


RE: RE: Slang Replacer by Keikonium on 07-16-2006 at 11:58 PM

quote:
Originally posted by cooldude_i06
They are called regular expressions. Here is more info:
http://authors.aspalliance.com/wsk/aboutregularexpression.asp


Oh, very informative :). There are quite a few of them, and that /r is EXACTLY what I needed :D. I was wondering how to get a script to notice nothing after a character (hitting enter :P). Thank you :).
RE: Slang Replacer by stuartbennett on 07-17-2006 at 05:47 AM

there seems to be quite some discussion and insight into this, i seem to have started quite a debate here. these all sound like great ideas cant wait to seem them in action.


RE: Slang Replacer by Ezra on 07-17-2006 at 08:33 AM

quote:
Originally posted by Silentdragon
Hmm wouldn't this be better?
code:
/\bbr\b/mgi

Doesn't need to check if its at the begining or not or space character as it looks for word boundries, And works with punctuation. Plus it doesn't chop out the space.

Also the writer should have did a spell check. Regards is not spelled reguards.

Word boundaries don't always work that great, that's why I always use (^|\s+) and ($|\s+).
RE: RE: Slang Replacer by stuartbennett on 07-22-2006 at 06:09 PM

quote:
Originally posted by Keikonium
Most people have semi good grammar, so this should be a nice little fix. When you type, you usually use spaces. Ex:

Bob says:
Hey John, I g2g, hospital time... :(
---> Hey John, I got to go, hospital time... :(

John says:
Okay, br buddy :)
---> Okay, best reguards buddy :)

So, a simple fix would be instead of:

sMessage = sMessage.replace(/br/gi,"best reguards");
make it
sMessage = sMessage.replace(/ br /gi," best reguards ");

:). Notice the space. This wont catch "br" at the end of a sentance however. But if you put an extra space at the end, it'll catch it ;).

This is how I wrote my personal script anyway.


i modified the script on my machine to have a space of br in the syntax as you suggested so it dont bring up breakfast as best regardseakfast the only think you get then is that even if you put a space after the br when you do want to say best regards the capital letter script messes up the word so it prevents the translation so i have to not use capital letter script at present.