line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::TransMetaphone::am; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# If either of these next two lines are inside |
4
|
|
|
|
|
|
|
# the BEGIN block the package will break. |
5
|
|
|
|
|
|
|
# |
6
|
1
|
|
|
1
|
|
6
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
7
|
1
|
|
|
1
|
|
945
|
use Regexp::Ethiopic::Amharic qw(:forms setForm overload); |
|
1
|
|
|
|
|
7824
|
|
|
1
|
|
|
|
|
6
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
BEGIN |
10
|
|
|
|
|
|
|
{ |
11
|
1
|
|
|
1
|
|
463
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
12
|
1
|
|
|
1
|
|
5
|
use vars qw( $VERSION $LocaleRange %IMExpected %IMError %plosives ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
101
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
219
|
$VERSION = '0.02'; |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
|
|
5
|
$LocaleRange = qr/[ሀ-ቍበ-ኾዐ-ዷጀ-ጕጠ-፼]/; |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
|
|
7
|
%plosives = ( |
19
|
|
|
|
|
|
|
k => 'ቀ', |
20
|
|
|
|
|
|
|
t => 'ጠ', |
21
|
|
|
|
|
|
|
ʧ => 'ጨ', |
22
|
|
|
|
|
|
|
s => 'ጸ', |
23
|
|
|
|
|
|
|
p => 'ጰ', |
24
|
|
|
|
|
|
|
); |
25
|
1
|
|
|
|
|
13
|
%IMExpected =( |
26
|
|
|
|
|
|
|
ስ => "s", |
27
|
|
|
|
|
|
|
ጽ => "s'", |
28
|
|
|
|
|
|
|
ቅ => "k'", |
29
|
|
|
|
|
|
|
ቕ => "q", |
30
|
|
|
|
|
|
|
ት => "t", |
31
|
|
|
|
|
|
|
ጥ => "t'", |
32
|
|
|
|
|
|
|
ች => "ʧ", |
33
|
|
|
|
|
|
|
ጭ => "ʧ", |
34
|
|
|
|
|
|
|
ን => "n", |
35
|
|
|
|
|
|
|
ክ => "k", |
36
|
|
|
|
|
|
|
ዝ => "z", |
37
|
|
|
|
|
|
|
ዥ => "ʒ", |
38
|
|
|
|
|
|
|
ጵ => "p'", |
39
|
|
|
|
|
|
|
ፕ => "p" |
40
|
|
|
|
|
|
|
); |
41
|
1
|
|
|
|
|
54
|
%IMError =( |
42
|
|
|
|
|
|
|
ስ => "s'", |
43
|
|
|
|
|
|
|
ጽ => "s", |
44
|
|
|
|
|
|
|
ቅ => "q", |
45
|
|
|
|
|
|
|
ቕ => "k'", |
46
|
|
|
|
|
|
|
ት => "t'", |
47
|
|
|
|
|
|
|
ጥ => "t", |
48
|
|
|
|
|
|
|
ች => "ʧ'", |
49
|
|
|
|
|
|
|
ጭ => "ʧ'", |
50
|
|
|
|
|
|
|
ን => "ɲ", |
51
|
|
|
|
|
|
|
ክ => "x", |
52
|
|
|
|
|
|
|
ዝ => "ʒ", |
53
|
|
|
|
|
|
|
ዥ => "z", |
54
|
|
|
|
|
|
|
ጵ => "p", |
55
|
|
|
|
|
|
|
ፕ => "p'" |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub trans_metaphone |
61
|
|
|
|
|
|
|
{ |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
1
|
0
|
3
|
$_ = $_[0]; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# |
66
|
|
|
|
|
|
|
# strip out all but first vowel: |
67
|
|
|
|
|
|
|
# |
68
|
1
|
|
|
|
|
6
|
s/^[=#አ#=]/a/; |
69
|
1
|
|
|
|
|
4
|
s/[=#አ#=]//g; |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
5
|
s/([#11#])/setForm($1,$ሳድስ)."ዋ"/eg; |
|
0
|
|
|
|
|
0
|
|
72
|
1
|
|
|
|
|
4
|
s/[=#ሀ#=]/h/g; |
73
|
1
|
|
|
|
|
30
|
s/[=#ሰ#=]/ሰ/g; |
74
|
1
|
|
|
|
|
3
|
s/[=#ጸ#=]/ጸ/g; |
75
|
|
|
|
|
|
|
# s/(.)[=#ጸ#=]/s'/g; # compare this to ts in english, it should be a 2nd key |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# |
78
|
|
|
|
|
|
|
# now strip vowels, this simplies later code: |
79
|
|
|
|
|
|
|
# |
80
|
1
|
50
|
|
|
|
5
|
s/(\p{InEthiopic})/ ($1 eq 'ኘ') ? $1 : setForm($1,$ሳድስ)/eg; |
|
4
|
|
|
|
|
66
|
|
81
|
|
|
|
|
|
|
|
82
|
1
|
|
|
|
|
30
|
tr/ልምርሽብቭውይድጅግፍ/lmrʃbvwjdʤgf/; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
1
|
|
|
|
|
2
|
my @keys = ( $_ ); |
86
|
1
|
|
|
|
|
3
|
my $re = $_; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# |
90
|
|
|
|
|
|
|
# mixed glyphs: ዽ for ጵ or ዽ is shift stick for ድ |
91
|
|
|
|
|
|
|
# |
92
|
1
|
50
|
|
|
|
5
|
if ( $keys[0] =~ /ዽ/ ) { |
93
|
0
|
|
|
|
|
0
|
$keys[2] = $keys[1] = $keys[0]; |
94
|
0
|
|
|
|
|
0
|
$keys[0] =~ s/ዽ/ɗ/; # caps problem |
95
|
0
|
|
|
|
|
0
|
$keys[1] =~ s/ዽ/d/; # literal |
96
|
0
|
|
|
|
|
0
|
$keys[2] =~ s/ዽ/p'/; # mistaken glyph |
97
|
0
|
|
|
|
|
0
|
$re =~ s/ዽ/([dɗ]|p')/g; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
# |
100
|
|
|
|
|
|
|
# mixed glyphs: ኘ for ፕ or ኘ is shift stick for ነ |
101
|
|
|
|
|
|
|
# |
102
|
1
|
50
|
|
|
|
5
|
if ( $keys[0] =~ /ኘ/ ) { |
103
|
0
|
|
|
|
|
0
|
my (@newKeysA, @newKeysB); |
104
|
0
|
|
|
|
|
0
|
for (my $i=0; $i < @keys; $i++) { |
105
|
0
|
|
|
|
|
0
|
$newKeysA[$i] = $newKeysB[$i] = $keys[$i]; # copy old keys |
106
|
0
|
|
|
|
|
0
|
$keys[$i] =~ s/ኘ/ɲ/; # literal |
107
|
0
|
|
|
|
|
0
|
$newKeysA[$i] =~ s/ኘ/n/; # caps problem |
108
|
0
|
|
|
|
|
0
|
$newKeysB[$i] =~ s/ኘ/p/; # mistaken glyph |
109
|
|
|
|
|
|
|
} |
110
|
0
|
|
|
|
|
0
|
push (@keys,@newKeysA); # add new keys to old keys |
111
|
0
|
|
|
|
|
0
|
push (@keys,@newKeysB); # add new keys to old keys |
112
|
0
|
|
|
|
|
0
|
$re =~ s/ኘ/[nɲp]/g; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
# |
115
|
|
|
|
|
|
|
# handle phonological problems |
116
|
|
|
|
|
|
|
# |
117
|
1
|
50
|
|
|
|
6
|
if ( $keys[0] =~ /mb/ ) { |
118
|
0
|
|
|
|
|
0
|
my @newKeys; |
119
|
0
|
|
|
|
|
0
|
for (my $i=0; $i < @keys; $i++) { |
120
|
0
|
|
|
|
|
0
|
$newKeys[$i] = $keys[$i]; # copy old keys |
121
|
0
|
|
|
|
|
0
|
$newKeys[$i] =~ s/mb/nb/; # update old keys for primary mapping |
122
|
|
|
|
|
|
|
} |
123
|
0
|
|
|
|
|
0
|
push (@keys,@newKeys); # add new keys to old keys |
124
|
0
|
|
|
|
|
0
|
$re =~ s/mb/[mn]b/g; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# |
128
|
|
|
|
|
|
|
# try to keep least probable keys last: |
129
|
|
|
|
|
|
|
# |
130
|
|
|
|
|
|
|
# |
131
|
|
|
|
|
|
|
# Handle IM problems |
132
|
|
|
|
|
|
|
# |
133
|
1
|
|
|
|
|
6
|
while ( $keys[0] =~ /([ስቅቕትችንክዝዥጥጭጽጵፕ])/ ) { |
134
|
2
|
|
|
|
|
4
|
my $a = $1; |
135
|
2
|
|
|
|
|
3
|
my @newKeys; |
136
|
2
|
|
|
|
|
8
|
for (my $i=0; $i < @keys; $i++) { |
137
|
3
|
|
|
|
|
6
|
$newKeys[$i] = $keys[$i]; # copy old keys |
138
|
3
|
|
|
|
|
37
|
$keys[$i] =~ s/$a/$IMExpected{$a}/; # update old keys for primary mapping |
139
|
|
|
|
|
|
|
} |
140
|
2
|
|
|
|
|
8
|
for (my $i=0; $i < @newKeys; $i++) { |
141
|
3
|
|
|
|
|
33
|
$newKeys[$i] =~ s/$a/$IMError{$a}/; # update new keys for alternative |
142
|
|
|
|
|
|
|
} |
143
|
2
|
|
|
|
|
5
|
push (@keys,@newKeys); # add new keys to old keys |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# print "$a => $IMExpected{$a} / $IMError{$a}\n"; |
146
|
2
|
100
|
66
|
|
|
15
|
if ( $plosives{$IMExpected{$a}} || $plosives{$IMError{$a}} ) { |
147
|
1
|
|
|
|
|
19
|
$re =~ s/$a/($IMExpected{$a}|$IMError{$a})/g; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
else { |
150
|
1
|
|
|
|
|
20
|
$re =~ s/$a/[$IMExpected{$a}$IMError{$a}]/g; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
1
|
50
|
|
|
|
4
|
if ( $#keys ) { |
155
|
1
|
|
|
|
|
31
|
push ( @keys, qr/$re/ ); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
1
|
|
|
|
|
8
|
@keys; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub reverse_key |
163
|
|
|
|
|
|
|
{ |
164
|
1
|
|
|
1
|
0
|
2
|
$_ = $_[0]; |
165
|
|
|
|
|
|
|
|
166
|
1
|
|
|
|
|
2
|
s/([stʧkp])'/$plosives{$1}/g; |
167
|
1
|
|
|
|
|
13
|
tr/hlmrsʃqbvtʧnɲakwjdɗʤzʒgɲfp/ሀለመረሰሸቐበቨተቸነኘአከወየደዸጀዘዠገጘፈፐ/; |
168
|
1
|
|
|
|
|
13
|
s/(\p{InEthiopic})/[#$1#]/g; |
169
|
1
|
|
|
|
|
3
|
s/ዸ/ደዸ/g; |
170
|
1
|
|
|
|
|
2
|
s/ጘ/ገጘ/g; |
171
|
|
|
|
|
|
|
|
172
|
1
|
|
|
|
|
5
|
$_; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
######################################################### |
178
|
|
|
|
|
|
|
# Do not change this, Do not put anything below this. |
179
|
|
|
|
|
|
|
# File must return "true" value at termination |
180
|
|
|
|
|
|
|
1; |
181
|
|
|
|
|
|
|
########################################################## |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
__END__ |