| Lingua-Alphabet-Phonetic documentation | Contained in the Lingua-Alphabet-Phonetic distribution. |
Lingua::Alphabet::Phonetic - map ABC's to phonetic alphabets
use Lingua::Alphabet::Phonetic;
my $oMilSpeaker = new Lingua::Alphabet::Phonetic('NATO');
my @asMilSpeak = $oMilSpeaker->enunciate('ABC');
At present, the only alphabet available for conversion is the U.S. Military / NATO standard where "ABC...YZ" is pronounced "Alpha Bravo Charlie ... Yankee Zulu". It is called 'NATO' and it is included with this distribution.
Create an object of this class. See SYNOPSIS above.
Given a string, returns a list of phonetic alphabet "words", one word per character of the original string. If there is no "word" in the alphabet for a character, that character is returned in the list position.
To create a conversion scheme for another alphabet, simply subclass this module and provide a method _name_of_letter() which takes a character and returns its phonetic name. See NATO.pm as an example.
http://en.wikipedia.org/wiki/Spelling_alphabet is a brief overview
http://www.bckelk.uklinux.net/phon.full.html contains a list of phonetic alphabets from all over the world!
Please tell the author if you find any!
This software is released under the same license as Perl itself.
Martin Thurn (mthurn@cpan.org).
| Lingua-Alphabet-Phonetic documentation | Contained in the Lingua-Alphabet-Phonetic distribution. |
# $Id: Phonetic.pm,v 1.9 2008/09/07 03:23:24 Martin Exp $
##################################################################### package Lingua::Alphabet::Phonetic; use strict; use warnings; our $VERSION = sprintf("%d.%02d", q$Revision: 1.9 $ =~ /(\d+)\.(\d+)/o);
sub new { my $class = shift; my $sAlphabet = shift || ''; my $sSubclass = "${class}::$sAlphabet"; eval "use $sSubclass"; Carp::croak("Unknown phonetic alphabet $sAlphabet: $@") if ($@); my $self = bless { }, $sSubclass; return $self; } # new
sub enunciate { my $self = shift; my $s = shift || ''; my @ac = split('', $s); return map { $self->_name_of_letter($_) } @ac; } # enunciate sub _name_of_letter { # This is the default fallback character --> word mapping. my $self = shift; my $s = shift; # Just return our argument unchanged: return $s; } # _name_of_letter
1; __END__