Just some fun with the proposed problem. Phonetics gone awry!
Obviously not complete or most efficient form, but just a few things to think about.
Enjoy!
dageek
#!/usr/bin/perl -w
use strict;
my $str = 'One day my 2 sisters gave me 100% of thier work. "How could
+ they?" I asked at 8:00 P.M.. "Easily" replied my subconcious, "Those
+ two want to go too.';
print "original string:\n$str\n\n";
## do all your special replacements in the order that works for most s
+ituations.
$str =~ s/100/ one hundred /g;
$str =~ s/00/ double ought /g;
$str =~ s/0/ zero /g;
$str =~ s/1/ one /g;
$str =~ s/2/ two /g;
$str =~ s/8/ eight /g;
$str =~ s/%/ percent /g;
$str =~ s/\?/ question mark /g;
$str =~ s/\./ period /g;
$str =~ s/\:/ colon /g;
$str =~ s/\"/ quotation mark /g;
## lower case all letters/ or if you like pain,
## prepend all upper case letters with the words "upper case"
$str=~s/([A-Z])/upper case $1/g;
$str=lc($str);
## make multiple spaces equal to one space
$str=~s/\s+/ /g;
## now Phoneticize to your heart's content
my %tran = ( a => " alpha ",
b=>" bravo ",
c=>" charlie ",
d=>" delta ",
e=>" echo ",
f=>" foxtrot ",
g=>" golf ",
h=>" hotel ",
i=>" indian ",
j=>" juliet ",
k=>" kilo ",
l=>" lima ",
m=>" mike ",
n=>" november ",
o=>" oscar ",
p=>" papa ",
q=>" quebec ",
r=>" romeo ",
s=>" siera ",
t=>" tango ",
u=>" uniform ",
v=>" victor ",
w=>" whiskey ",
x=>" xray ",
y=>" yankee ",
z=>" zulu "
);
print "$str\n\n";
my $endstr = "";
## now create the phoneticized sentence
foreach (split //, $str)
{
if (exists $tran{$_})
{
$endstr = $endstr . "$tran{$_}";
}
else
{
## or add $_ as another answer suggested
$endstr = $endstr . "/";
}
}
## get rid of extra spaces
$endstr=~ s/\s+/ /g;
## show em your stuff
print "$endstr\n";
|