summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2009-06-07 00:24:01 -0500
committerJesse Luehrs <doy@tozt.net>2009-06-07 00:24:01 -0500
commitdaf298f347a3b7244d897dd12d2fccb3cda746cf (patch)
tree4738b8fcf3313419925ed55385b4f92712b1f9a0
parentfc5f9edb2ac8d2f4f6e23a24825f42e062fd5ac2 (diff)
downloadlingua-hi-romanize-daf298f347a3b7244d897dd12d2fccb3cda746cf.tar.gz
lingua-hi-romanize-daf298f347a3b7244d897dd12d2fccb3cda746cf.zip
transliteration types should get their own packages
-rw-r--r--lib/Lingua/HI/Romanize.pm44
1 files changed, 20 insertions, 24 deletions
diff --git a/lib/Lingua/HI/Romanize.pm b/lib/Lingua/HI/Romanize.pm
index 8dfdda9..694dd48 100644
--- a/lib/Lingua/HI/Romanize.pm
+++ b/lib/Lingua/HI/Romanize.pm
@@ -11,43 +11,39 @@ has unicode => (
has default_ascii => (
is => 'ro',
isa => 'Str',
- default => 'itrans',
+ default => 'ITRANS',
);
has default_unicode => (
is => 'ro',
isa => 'Str',
- default => 'iast',
+ default => 'IAST',
);
sub romanize {
my $self = shift;
- my $method = "romanize_";
+ my ($text) = @_;
+ my $package = 'Lingua::HI::Romanize::';
if ($self->unicode) {
- $method .= $self->default_unicode;
+ $package .= $self->default_unicode;
}
else {
- $method .= $self->default_ascii;
+ $package .= $self->default_ascii;
}
- return $self->$method(@_);
-}
-
-sub romanize_iast {
-}
-
-sub romanize_kolkata {
-}
-
-sub romanize_iso15919 {
-}
-
-sub romanize_harvard_kyoto {
-}
-
-sub romanize_itrans {
-}
-
-sub romanize_velthuis {
+ my %translit = %{ $package->TRANSLIT };
+ my $output = '';
+ for my $word (split /\b/s, $text) {
+ for my $char (split //, $word) {
+ if (exists $translit{$char}) {
+ $output .= $translit{$char};
+ }
+ else {
+ $output .= $char;
+ }
+ }
+ # XXX: word-final 'a' should be stripped
+ }
+ return $output;
}
1;