Acme-Albed
view release on metacpan or search on metacpan
lib/Acme/Albed.pm view on Meta::CPAN
package Acme::Albed;
use utf8;
use Any::Moose;
our $VERSION = '0.03';
has albedian => (
is => 'rw',
isa => 'Int',
default => 0,
);
has dict => (
is => 'rw',
isa => 'HashRef',
lazy => 1,
default => sub {
my $dict = {
a => { before => 'ããããã', after => 'ã¯ãããã', },
ka => { before => 'ããããã', after => 'ã¢ãã«ãã¨', },
sa => { before => 'ããããã', after => 'ã©ãããã', },
ta => { before => 'ãã¡ã¤ã¦ã¨', after => 'ãµãã¦ã»ã½', },
na => { before => 'ãªã«ã¬ãã®', after => 'ãã·ã¹ã¡ãª', },
ha => { before => 'ã¯ã²ãµã¸ã»', after => 'ããªã¯ã±ã', },
ma => { before => 'ã¾ã¿ããã', after => 'ã¤ã¤ãã¬ã³', },
ya => { before => 'ããã', after => 'ã¿ã¢ã²', },
ra => { before => 'ããããã', after => 'ããã¦ã¨ã', },
wa => { before => 'ããã', after => 'ã«ã ã³', },
ga => { before => 'ããããã', after => 'ããã
ãã¾', },
za => { before => 'ããããã', after => 'ãããã²ã', },
da => { before => 'ã ã¢ã¥ã§ã©', after => 'ã¬ã®ã°ãã´', },
ba => { before => 'ã°ã³ã¶ã¹ã¼', after => 'ã¶ã¸ãºã¼ã', },
pa => { before => 'ã±ã´ã·ãºã½', after => 'ããããã', },
la => { before => 'ããã
ãã', after => 'ã¡ã£ã¥ã§ã©', },
ltu => { before => 'ã£ãã
ã', after => 'ãã£ã¥ã§', },
en => {
before => 'abcdefghijklmnopqrstuvwxyz',
after => 'ypltavkrezgmshubxncdijfqow',
},
};
return $dict;
},
);
sub to_albed {
my ( $self, $arg ) = @_;
return unless defined $arg;
$self->albedian(0);
$self->_conv($arg);
}
sub from_albed {
my ( $self, $arg ) = @_;
return unless defined $arg;
$self->albedian(1);
$self->_conv($arg);
}
sub _conv {
my ( $self, $message ) = @_;
my $res;
my $dict = $self->dict;
my @mos = keys(%$dict);
my @message = split //, $message;
for my $i ( 0 .. $#message ) {
my $char = $message[$i];
if ( $char =~ /(\s|\t|\n)/ ) {
$res .= $char;
}
else {
return unless ( defined $char && $char ne "" );
my $enc;
foreach my $key (@mos) {
$" = "|";
my ( $source, $conv ) = $self->_resource( $dict->{$key} );
my @source = split //, $source;
my @conv = split //, $conv;
( run in 0.691 second using v1.01-cache-2.11-cpan-39bf76dae61 )