line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Used to translate roman key board strokes to Unicode.
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Unicode::Indic::Phonetic;
|
4
|
1
|
|
|
1
|
|
5
|
use strict;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1181
|
|
5
|
|
|
|
|
|
|
our $VERSION = 0.01;
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new {
|
8
|
0
|
|
|
0
|
0
|
0
|
my $proto = shift;
|
9
|
0
|
|
0
|
|
|
0
|
my $class = ref($proto)||$proto;
|
10
|
0
|
|
|
|
|
0
|
my $self = {
|
11
|
|
|
|
|
|
|
@_
|
12
|
|
|
|
|
|
|
};
|
13
|
|
|
|
|
|
|
}
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub translate{
|
16
|
1
|
|
|
1
|
0
|
42
|
my $self = shift;
|
17
|
1
|
|
|
|
|
4
|
my $map = $self ->{Map};
|
18
|
1
|
|
|
|
|
3
|
my $text = shift;
|
19
|
1
|
|
|
|
|
2
|
my $prev = '';
|
20
|
1
|
|
|
|
|
1
|
my $boc = 1;
|
21
|
1
|
|
|
|
|
3
|
my $out;
|
22
|
1
|
|
|
|
|
3
|
my $flag = '';
|
23
|
1
|
|
|
|
|
3
|
my $halant = $map->{virama};
|
24
|
1
|
|
|
|
|
12
|
foreach my $ch (split (//, $text),' '){
|
25
|
36
|
50
|
|
|
|
67
|
if ($flag ne ''){
|
26
|
0
|
0
|
0
|
|
|
0
|
$flag = '' if ($flag eq '<' && $ch eq '>');
|
27
|
0
|
0
|
0
|
|
|
0
|
$flag = '' if ($flag eq '&' && $ch eq ';');
|
28
|
0
|
0
|
0
|
|
|
0
|
if ($flag eq '#' && $ch eq '#'){
|
29
|
0
|
|
|
|
|
0
|
$flag = '';
|
30
|
0
|
|
|
|
|
0
|
$out .= '\e';
|
31
|
0
|
|
|
|
|
0
|
next;
|
32
|
|
|
|
|
|
|
}
|
33
|
0
|
0
|
|
|
|
0
|
if ($flag ne ''){
|
34
|
0
|
0
|
|
|
|
0
|
$out .= $ch unless $ch eq '#';
|
35
|
0
|
0
|
|
|
|
0
|
$out .= '\e' if $ch eq '#';
|
36
|
0
|
|
|
|
|
0
|
next;
|
37
|
|
|
|
|
|
|
}
|
38
|
|
|
|
|
|
|
}
|
39
|
36
|
100
|
|
|
|
56
|
if (!$prev){
|
40
|
5
|
|
|
|
|
8
|
$prev = $ch;
|
41
|
5
|
|
|
|
|
8
|
next;
|
42
|
|
|
|
|
|
|
}
|
43
|
31
|
100
|
66
|
|
|
91
|
$out .= $halant if (!$boc && $prev !~ /[aeiouAEIOUMHR]/);
|
44
|
31
|
100
|
|
|
|
91
|
if (exists $map->{$prev.$ch}){
|
|
|
100
|
|
|
|
|
|
45
|
4
|
50
|
33
|
|
|
15
|
if ($boc && $ch =~ /[aieouAEIOUMHR]/){
|
46
|
0
|
|
|
|
|
0
|
$out .= $map->{'_'.$prev.$ch};
|
47
|
|
|
|
|
|
|
}else{
|
48
|
4
|
|
|
|
|
6
|
$out .= $map->{$prev.$ch};
|
49
|
|
|
|
|
|
|
}
|
50
|
4
|
|
|
|
|
7
|
$prev ='';
|
51
|
4
|
|
|
|
|
10
|
$boc = ($ch =~ /[aieouAEIOUMHR]/);
|
52
|
|
|
|
|
|
|
}elsif (exists $map->{$prev}){
|
53
|
23
|
50
|
66
|
|
|
78
|
if ($boc && $prev =~ /[aieouAEIOUR]/){
|
54
|
0
|
|
|
|
|
0
|
$out .= $map->{'_'.$prev};
|
55
|
|
|
|
|
|
|
}else{
|
56
|
23
|
100
|
|
|
|
56
|
$out .= $map->{$prev} if $map->{$prev};
|
57
|
|
|
|
|
|
|
}
|
58
|
23
|
|
|
|
|
40
|
$boc = ($prev =~ /[aieouAEIOUMHR]/);
|
59
|
23
|
|
|
|
|
37
|
$prev = $ch;
|
60
|
|
|
|
|
|
|
}else{
|
61
|
4
|
50
|
|
|
|
12
|
$out .= $prev unless $prev eq '#';
|
62
|
4
|
50
|
|
|
|
11
|
$out .= '\e' if $prev eq '#';
|
63
|
4
|
|
|
|
|
5
|
$boc = 1;
|
64
|
4
|
50
|
33
|
|
|
41
|
if ((($prev eq '&') || ($prev eq '<'))|| ($prev eq '#')){
|
|
|
|
33
|
|
|
|
|
65
|
0
|
|
|
|
|
0
|
$flag = $prev;
|
66
|
0
|
|
|
|
|
0
|
$out .= $ch;
|
67
|
0
|
|
|
|
|
0
|
$prev = '';
|
68
|
|
|
|
|
|
|
}else{
|
69
|
4
|
|
|
|
|
5
|
$prev = $ch;
|
70
|
|
|
|
|
|
|
}
|
71
|
|
|
|
|
|
|
}
|
72
|
|
|
|
|
|
|
}
|
73
|
1
|
|
|
|
|
14
|
return $out;
|
74
|
|
|
|
|
|
|
}
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub romanise{
|
77
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
78
|
0
|
|
|
|
|
|
my $map = $self ->{Map};
|
79
|
0
|
0
|
|
|
|
|
$self->{RMap} = $self->rmap() unless exists $self->{RMap};
|
80
|
0
|
|
|
|
|
|
my $rmap = $self ->{RMap};
|
81
|
0
|
|
|
|
|
|
my $base = ord($map->{base});
|
82
|
0
|
|
|
|
|
|
my $text = shift;
|
83
|
0
|
|
|
|
|
|
my $prev = 'a';
|
84
|
0
|
|
|
|
|
|
my $out;
|
85
|
0
|
|
|
|
|
|
my $halant = $map->{virama};
|
86
|
0
|
|
|
|
|
|
foreach my $ch (split (//, $text),' '){
|
87
|
0
|
0
|
|
|
|
|
if (ord($ch) >= $base){
|
88
|
0
|
|
|
|
|
|
my $ch1 .= $rmap->[ord($ch) - $base];
|
89
|
0
|
0
|
|
|
|
|
if ($ch eq $halant){
|
90
|
0
|
|
|
|
|
|
$prev = 'a';
|
91
|
0
|
|
|
|
|
|
next;
|
92
|
|
|
|
|
|
|
}
|
93
|
0
|
0
|
|
|
|
|
$out .= 'a' if "$prev.$ch1" !~ /[aeiouAEIOUMHR]/;
|
94
|
0
|
|
|
|
|
|
$out .= $ch1;
|
95
|
0
|
|
|
|
|
|
$prev = $ch1;
|
96
|
|
|
|
|
|
|
}else{
|
97
|
0
|
0
|
|
|
|
|
$out .= 'a' if $prev !~ /[aeiouAEIOUMHR]/;
|
98
|
0
|
0
|
|
|
|
|
$out .= '#' if $ch eq '\e';
|
99
|
0
|
|
|
|
|
|
$out .= $ch;
|
100
|
0
|
|
|
|
|
|
$prev = 'a';
|
101
|
|
|
|
|
|
|
}
|
102
|
|
|
|
|
|
|
}
|
103
|
0
|
|
|
|
|
|
return $out;
|
104
|
|
|
|
|
|
|
}
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub rmap{
|
107
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
108
|
0
|
|
|
|
|
|
my $Map = $self->{Map};
|
109
|
0
|
|
|
|
|
|
my $base = ord($Map->{base});
|
110
|
0
|
|
|
|
|
|
my $RMap = [];
|
111
|
0
|
|
|
|
|
|
foreach my $key (sort keys %{$Map}){
|
|
0
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
my $v = ord($Map->{$key}) - $base;
|
113
|
0
|
0
|
0
|
|
|
|
next if $v < 0 or length $key > 3;
|
114
|
|
|
|
|
|
|
#print $v, ": ", $key,"\n";
|
115
|
0
|
|
|
|
|
|
$key =~ s/^_//;
|
116
|
0
|
|
|
|
|
|
$RMap->[$v] = $key;
|
117
|
|
|
|
|
|
|
}
|
118
|
0
|
|
|
|
|
|
return $RMap;
|
119
|
|
|
|
|
|
|
}
|
120
|
|
|
|
|
|
|
1;
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
__END__
|