| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Text::WagnerFischer::Amharic; |
|
2
|
1
|
|
|
1
|
|
25335
|
use base qw( Text::WagnerFischer ); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
831
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
890
|
use utf8; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
|
|
BEGIN |
|
6
|
|
|
|
|
|
|
{ |
|
7
|
1
|
|
|
1
|
|
28
|
use strict; |
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
29
|
|
|
8
|
1
|
|
|
1
|
|
4
|
use vars qw( @EXPORT_OK %IMCapsMismatch $VERSION ); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
186
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
1492
|
use Regexp::Ethiopic::Amharic ( 'getForm', 'setForm', ':forms' ); |
|
|
1
|
|
|
|
|
36308
|
|
|
|
1
|
|
|
|
|
6
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
690
|
$VERSION = "0.01"; |
|
13
|
|
|
|
|
|
|
# |
|
14
|
|
|
|
|
|
|
# This linking is done so that the export of "distance" works |
|
15
|
|
|
|
|
|
|
# as before: |
|
16
|
|
|
|
|
|
|
# |
|
17
|
1
|
|
|
|
|
3
|
*distance = \&Text::WagnerFischer::distance; |
|
18
|
1
|
|
|
|
|
3
|
@EXPORT_OK = qw( distance ); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# |
|
22
|
|
|
|
|
|
|
# "override" the _weight function with the local one: |
|
23
|
|
|
|
|
|
|
# |
|
24
|
1
|
|
|
|
|
19
|
*Text::WagnerFischer::_weight = \&_am_weight; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# |
|
28
|
|
|
|
|
|
|
# Set a new default cossts: |
|
29
|
|
|
|
|
|
|
# |
|
30
|
|
|
|
|
|
|
# WagnerFischer : equal, insert/delete, mismatch, |
|
31
|
|
|
|
|
|
|
# Right Family but: phoneme/glyph equiv, zemene, wrong form |
|
32
|
|
|
|
|
|
|
# Right Form but : phoneme/glyph equiv, shift slip, wrong base |
|
33
|
|
|
|
|
|
|
# other : phoneme equiv |
|
34
|
1
|
|
|
|
|
4
|
$Text::WagnerFischer::REFC = [0,2,3, 1,2,1, 1,1,2, 1]; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
526
|
%IMCapsMismatch =( |
|
38
|
|
|
|
|
|
|
ስ => "ጽ", |
|
39
|
|
|
|
|
|
|
ጽ => "ስ", |
|
40
|
|
|
|
|
|
|
ቅ => "ቕ", |
|
41
|
|
|
|
|
|
|
ቕ => "ቅ", |
|
42
|
|
|
|
|
|
|
ት => "ጥ", |
|
43
|
|
|
|
|
|
|
ጥ => "ት", |
|
44
|
|
|
|
|
|
|
ች => "ጭ", |
|
45
|
|
|
|
|
|
|
ጭ => "ች", |
|
46
|
|
|
|
|
|
|
ን => "ኝ", |
|
47
|
|
|
|
|
|
|
ኝ => "ን", |
|
48
|
|
|
|
|
|
|
ክ => "ኽ", |
|
49
|
|
|
|
|
|
|
ኽ => "ክ", |
|
50
|
|
|
|
|
|
|
ዝ => "ዥ", |
|
51
|
|
|
|
|
|
|
ዥ => "ዝ", |
|
52
|
|
|
|
|
|
|
ጵ => "ፕ", |
|
53
|
|
|
|
|
|
|
ፕ => "ጵ" |
|
54
|
|
|
|
|
|
|
); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _am_weight |
|
60
|
|
|
|
|
|
|
{ |
|
61
|
135
|
|
|
135
|
|
5597
|
my ($x,$y,$refc)=@_; |
|
62
|
|
|
|
|
|
|
|
|
63
|
135
|
|
|
|
|
136
|
my $value; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# print "Comparing: $x/$y\n"; |
|
66
|
|
|
|
|
|
|
|
|
67
|
135
|
100
|
100
|
|
|
1092
|
if ($x eq $y) { |
|
|
|
100
|
|
|
|
|
|
|
68
|
8
|
|
|
|
|
10
|
$value = $refc->[0]; # cost for letter match |
|
69
|
|
|
|
|
|
|
} elsif ( ($x eq '-') or ($y eq '-') ) { |
|
70
|
90
|
|
|
|
|
124
|
$value = $refc->[1]; # cost for insertion/deletion operation |
|
71
|
|
|
|
|
|
|
} else { |
|
72
|
37
|
|
|
|
|
91
|
my $yግዕዝ = setForm ( $y, $ግዕዝ ); |
|
73
|
|
|
|
|
|
|
|
|
74
|
37
|
|
|
|
|
521
|
my $yEquiv = Regexp::Ethiopic::Amharic::getRe ( "[=$yግዕዝ=]" ); |
|
75
|
37
|
|
|
|
|
921
|
my $yFamily = Regexp::Ethiopic::Amharic::getRe ( "[#$yግዕዝ#]" ); |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# print " $yግዕዝ: $yEquiv / $yFamily\n"; |
|
78
|
|
|
|
|
|
|
# print "yEquiv/yFamily: <$yEquiv><$yFamily>\n"; |
|
79
|
|
|
|
|
|
|
|
|
80
|
37
|
50
|
33
|
|
|
1155
|
if ( $x =~ /$yFamily/ ) { # x & y are in the same family |
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
81
|
0
|
0
|
0
|
|
|
0
|
if ( $yEquiv && $x =~ /$yEquiv/ ) { |
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
82
|
0
|
|
|
|
|
0
|
$value = $refc->[3]; # phono/glyph equivalence: ኮ/ኰ, ቁ/ቍ |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
elsif ( ($x =~ /[ዉው]/) && ($y =~ /[ዉው]/) ) { |
|
85
|
0
|
|
|
|
|
0
|
$value = $refc->[3]; # |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
elsif ( (getForm($x) > 7) || (getForm($y) > 7) ) { |
|
88
|
0
|
|
|
|
|
0
|
$value = $refc->[4]; # labiovelar mismatch |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
else { |
|
91
|
0
|
|
|
|
|
0
|
$value = $refc->[5]; # form mismatch |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
} elsif ( getForm($x) == getForm($y) ) { # right form, wrong family |
|
94
|
22
|
100
|
66
|
|
|
549
|
if ( $yEquiv && $x =~ /$yEquiv/ ) { |
|
95
|
5
|
|
|
|
|
12
|
$value = $refc->[6]; # phono/glyph equivalence: ሳ/ሣ |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
else { |
|
98
|
17
|
|
|
|
|
39
|
my $xሳድስ = setForm ( $x, $ሳድስ ); |
|
99
|
17
|
|
|
|
|
194
|
my $yሳድስ = setForm ( $y, $ሳድስ ); |
|
100
|
17
|
50
|
|
|
|
185
|
if ( $IMCapsEquivalence{$xሳድስ} eq $yሳድስ ) { |
|
101
|
0
|
|
|
|
|
0
|
$value = $refc->[7]; # finger slipped on shift key: ት/ጥ |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
else { |
|
104
|
17
|
|
|
|
|
33
|
$value = $refc->[8]; # family mismatch |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
} elsif ( $yEquiv && $x =~ /$yEquiv/ ) { # different family, differnt form but related: ሀ/ሐ/ኀ/ሃ/ሓ/ኃ/ኻ |
|
108
|
0
|
|
|
|
|
0
|
$value = $refc->[9]; |
|
109
|
|
|
|
|
|
|
} else { |
|
110
|
15
|
|
|
|
|
535
|
$value = $refc->[2]; # cost for letter mismatch |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# print "Comparing: $x/$y => $value\n"; |
|
115
|
135
|
|
|
|
|
405
|
$value; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
######################################################### |
|
120
|
|
|
|
|
|
|
# Do not change this, Do not put anything below this. |
|
121
|
|
|
|
|
|
|
# File must return "true" value at termination |
|
122
|
|
|
|
|
|
|
1; |
|
123
|
|
|
|
|
|
|
########################################################## |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
__END__ |