I'm not a big acronym user, finding it generally faster to type what I'm thinking than abbreviate it. However, I often find myself on the receiving end of acronyms that I have no idea what they mean. For fun, I went onto the web and scraped a few web pages listing hundreds of common chat acronyms and made a tool that I can use to very easily translate these on the fly while using iChat.
I made two scripts that work together, allowing me to highlight text in iChat and get a quick translation of any acronyms in the highlighted text. Due to the fact that the perl script was a few thousand lines with all the definitions, I've cut out all but four acronyms so that folks can add their own or contact me for the full set of definitions if they want. As the definitions were simply scraped off the web, I make no claims on the quality of the content of the translations which also contain some swear words. You might wish to create your own list of definitions and add them to the script.
I'm a self taught scripter, so I'm sure there might be shorter and or better ways to do this. It's intended to be able to translate whole sentences containing acronyms, and the way it handles deconstructing white space and punctuation and re-assembling them might be handled better, but it seems to work fine for me as is.
Some notes:
tell application "iChat"
activate
end tell
tell application "System Events"
tell process "iChat"
keystroke "c" using {command down}
delay 2
set myData to (the clipboard) as text
end tell
end tell
do shell script "perl ~/bin/im_translator_ichat.pl " & "\"" & myData & "\""
Perl:
#!/usr/bin/perl -w
use strict;
my $out = "";
my ($im_acronym, $im_translation) = &define_translation_hashes();
my %im_acronym = %{$im_acronym};
my %im_translation = %{$im_translation};
my $string = $ARGV[0];
my @string = ();
################################################
@string = &split_on_white($string);
&translate(\@string);
for(@string){
if($_ =~ m/^[.?!,]$/m){
$out .= "$_";
}
else{
$out .= " $_";
}
}
my $SCRIPT =<<EOS;
tell application "iChat"
activate
display dialog "$out"
end tell
EOS
open (FH, "|/usr/bin/osascript");
print FH $SCRIPT;
close FH;
exit;
################################################
sub split_on_white(){
my $string = shift @_;
#all white space to single spaces
$string =~ s![ \t]+! !mig;
$string =~ s/([.,!?])/ $1/mig;
my @string = split (/ /, $string);
}
sub translate(){
my $string = shift @_;
for(@{$string}){
my $cur_string = $_;
#Check each for match to %im_acronym
foreach my $key(sort keys %im_acronym){
if($im_acronym{$key} =~ m#^\Q${cur_string}\E$#im){
$_ = $im_translation{$key};
}
} }
}
################################################
sub define_translation_hashes(){
my %im_acronym = (
im_acronym1 => "AFAIK",
im_acronym2 => "IMHO",
im_acronym3 => "BTW",
im_acronym4 => "HTH",
#ADD FURTHER ACRONYMS HERE
);
my %im_translation = (
im_acronym1 => "as far as I know",
im_acronym2 => "in my humble opinion",
im_acronym3 => "by the way",
im_acronym4 => "hope that helps",
#ADD CORRESPONDING TRANSLATION HERE
);
my $im_translation = \%im_translation;
my $im_acronym = \%im_acronym;
return ($im_acronym, $im_translation);
}
################################################
Mac OS X Hints
http://hints.macworld.com/article.php?story=20040812190839795