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";

In reply to Re: Phonetic Translation by johndageek
in thread Phonetic Translation by ellem

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.