| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Acme::Albed; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
6569
|
use utf8; |
|
|
2
|
|
|
|
|
27
|
|
|
|
2
|
|
|
|
|
13
|
|
|
4
|
2
|
|
|
2
|
|
11259
|
use Any::Moose; |
|
|
2
|
|
|
|
|
76423
|
|
|
|
2
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has albedian => ( |
|
9
|
|
|
|
|
|
|
is => 'rw', |
|
10
|
|
|
|
|
|
|
isa => 'Int', |
|
11
|
|
|
|
|
|
|
default => 0, |
|
12
|
|
|
|
|
|
|
); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has dict => ( |
|
15
|
|
|
|
|
|
|
is => 'rw', |
|
16
|
|
|
|
|
|
|
isa => 'HashRef', |
|
17
|
|
|
|
|
|
|
lazy => 1, |
|
18
|
|
|
|
|
|
|
default => sub { |
|
19
|
|
|
|
|
|
|
my $dict = { |
|
20
|
|
|
|
|
|
|
a => { before => 'あいうえお', after => 'ワミフネト', }, |
|
21
|
|
|
|
|
|
|
ka => { before => 'かきくけこ', after => 'アチルテヨ', }, |
|
22
|
|
|
|
|
|
|
sa => { before => 'さしすせそ', after => 'ラキヌヘホ', }, |
|
23
|
|
|
|
|
|
|
ta => { before => 'たちつてと', after => 'サヒユセソ', }, |
|
24
|
|
|
|
|
|
|
na => { before => 'なにぬねの', after => 'ハシスメオ', }, |
|
25
|
|
|
|
|
|
|
ha => { before => 'はひふへほ', after => 'マリクケロ', }, |
|
26
|
|
|
|
|
|
|
ma => { before => 'まみむめも', after => 'ヤイツレコ', }, |
|
27
|
|
|
|
|
|
|
ya => { before => 'やゆよ', after => 'タモヲ', }, |
|
28
|
|
|
|
|
|
|
ra => { before => 'らりるれろ', after => 'ナニウエノ', }, |
|
29
|
|
|
|
|
|
|
wa => { before => 'わをん', after => 'カムン', }, |
|
30
|
|
|
|
|
|
|
ga => { before => 'がぎぐげご', after => 'ダヂヅデゾ', }, |
|
31
|
|
|
|
|
|
|
za => { before => 'ざじずぜぞ', after => 'バビブゲボ', }, |
|
32
|
|
|
|
|
|
|
da => { before => 'だぢづでど', after => 'ガギグベゴ', }, |
|
33
|
|
|
|
|
|
|
ba => { before => 'ばびぶべぼ', after => 'ザジズゼド', }, |
|
34
|
|
|
|
|
|
|
pa => { before => 'ぱぴぷぺぽ', after => 'プポピパペ', }, |
|
35
|
|
|
|
|
|
|
la => { before => 'ぁぃぅぇぉ', after => 'ァィゥェォ', }, |
|
36
|
|
|
|
|
|
|
ltu => { before => 'っゃゅょ', after => 'ッャュョ', }, |
|
37
|
|
|
|
|
|
|
en => { |
|
38
|
|
|
|
|
|
|
before => 'abcdefghijklmnopqrstuvwxyz', |
|
39
|
|
|
|
|
|
|
after => 'ypltavkrezgmshubxncdijfqow', |
|
40
|
|
|
|
|
|
|
}, |
|
41
|
|
|
|
|
|
|
}; |
|
42
|
|
|
|
|
|
|
return $dict; |
|
43
|
|
|
|
|
|
|
}, |
|
44
|
|
|
|
|
|
|
); |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub to_albed { |
|
47
|
128
|
|
|
128
|
0
|
1110
|
my ( $self, $arg ) = @_; |
|
48
|
128
|
100
|
|
|
|
295
|
return unless defined $arg; |
|
49
|
127
|
|
|
|
|
474
|
$self->albedian(0); |
|
50
|
127
|
|
|
|
|
294
|
$self->_conv($arg); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub from_albed { |
|
54
|
125
|
|
|
125
|
0
|
216
|
my ( $self, $arg ) = @_; |
|
55
|
125
|
100
|
|
|
|
257
|
return unless defined $arg; |
|
56
|
124
|
|
|
|
|
497
|
$self->albedian(1); |
|
57
|
124
|
|
|
|
|
313
|
$self->_conv($arg); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _conv { |
|
61
|
251
|
|
|
251
|
|
402
|
my ( $self, $message ) = @_; |
|
62
|
251
|
|
|
|
|
257
|
my $res; |
|
63
|
251
|
|
|
|
|
591
|
my $dict = $self->dict; |
|
64
|
251
|
|
|
|
|
1761
|
my @mos = keys(%$dict); |
|
65
|
251
|
|
|
|
|
1017
|
my @message = split //, $message; |
|
66
|
251
|
|
|
|
|
677
|
for my $i ( 0 .. $#message ) { |
|
67
|
427
|
|
|
|
|
1010
|
my $char = $message[$i]; |
|
68
|
427
|
100
|
|
|
|
2019
|
if ( $char =~ /(\s|\t|\n)/ ) { |
|
69
|
3
|
|
|
|
|
12
|
$res .= $char; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
else { |
|
72
|
424
|
50
|
33
|
|
|
1955
|
return unless ( defined $char && $char ne "" ); |
|
73
|
424
|
|
|
|
|
406
|
my $enc; |
|
74
|
424
|
|
|
|
|
621
|
foreach my $key (@mos) { |
|
75
|
7632
|
|
|
|
|
11109
|
$" = "|"; |
|
76
|
7632
|
|
|
|
|
22865
|
my ( $source, $conv ) = $self->_resource( $dict->{$key} ); |
|
77
|
7632
|
|
|
|
|
39633
|
my @source = split //, $source; |
|
78
|
7632
|
|
|
|
|
24236
|
my @conv = split //, $conv; |
|
79
|
7632
|
100
|
|
|
|
307577
|
if ( $char =~ /(@source)/ ) { |
|
80
|
424
|
|
|
|
|
1524
|
for my $i ( 0 .. $#source ) { |
|
81
|
4240
|
100
|
|
|
|
10160
|
if ( $char eq $source[$i] ) { |
|
82
|
424
|
|
|
|
|
1070
|
$enc = $conv[$i]; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
} |
|
87
|
424
|
50
|
|
|
|
910
|
if (defined $enc) { |
|
88
|
424
|
|
|
|
|
1115
|
$res .= $enc; |
|
89
|
|
|
|
|
|
|
} else { |
|
90
|
0
|
|
|
|
|
0
|
$res .= $char; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
} |
|
94
|
251
|
|
|
|
|
2128
|
return $res; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub _resource { |
|
98
|
7632
|
|
|
7632
|
|
10273
|
my ( $self, $dict ) = @_; |
|
99
|
7632
|
100
|
|
|
|
28352
|
if ( $self->albedian ) { |
|
100
|
3816
|
|
|
|
|
11599
|
return ( $dict->{after}, $dict->{before} ); |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
else { |
|
103
|
3816
|
|
|
|
|
12291
|
return ( $dict->{before}, $dict->{after} ); |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
1; |
|
107
|
|
|
|
|
|
|
__END__ |