blib/lib/Text/WagnerFischer/Amharic.pm

filter: Statementstmt 85.7% 42 / 49 Branchbran 55.0% 11 / 20 Conditioncond 33.3% 6 / 18 MC/DCmcdc 25.0% 3 / 12 Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 65.4% 70 / 107 CC 17 SCAR 34.4
CC
17
Cov
68%
_am_weight
43.6
BEGIN
1.0
BEGIN
1.0
CRAP 31.2
↑ Summary
1 package Text::WagnerFischer::Amharic;
2 1 ▶use base qw( Text::WagnerFischer );
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 BEGIN
6 1 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use vars qw( @EXPORT_OK %IMCapsMismatch $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use Regexp::Ethiopic::Amharic ( 'getForm', 'setForm', ':forms' );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 $VERSION = "0.06";
14 #
15 # This linking is done so that the export of "distance" works
16 # as before:
17 #
18 1 *distance = \&Text::WagnerFischer::distance;
19 1 @EXPORT_OK = qw( &distance );
20  
21  
22 #
23 # "override" the _weight function with the local one:
24 #
25 1 *Text::WagnerFischer::_weight = \&_am_weight;
26  
27  
28 #
29 # Set a new default penalty costs:
30 #
31 # WagnerFischer : equal, insert/delete, mismatch,
32 # Right Family but: phoneme/glyph equiv, zemene, wrong form
33 # Right Form but : phoneme/glyph equiv, shift slip, wrong base
34 # other : phoneme equiv
35 1 $Text::WagnerFischer::REFC = [0,2,3, 1,2,1, 1,1,2, 1];
36  
37  
38 1 %IMCapsMismatch =(
39 ስ => "ጽ",
40 ጽ => "ስ",
41 ቅ => "ቕ",
42 ቕ => "ቅ",
43 ት => "ጥ",
44 ጥ => "ት",
45 ች => "ጭ",
46 ጭ => "ች",
47 ን => "ኝ",
48 ኝ => "ን",
49 ክ => "ኽ",
50 ኽ => "ክ",
51 ዝ => "ዥ",
52 ዥ => "ዝ",
53 ጵ => "ፕ",
54 ፕ => "ጵ"
55 );
56 }
57  
58  
59  
60 sub _am_weight
61 135 ▶{
Subroutine _am_weight: called CC=17 SCAR=37.8
62 135 my ($x,$y,$refc)=@_;
63  
64 135 my $value;
65  
66 # print "Comparing: $x/$y\n";
67  
68 135 ▶ if ($x eq $y) {
Branch: 2 branches
BranchTrueFalseTotal
if ($x eq $y) { } 8 127 135
elsif ($x eq '-' or $y eq '-') { } 90 37 127
69 8 $value = $refc->[0]; # cost for letter match
70 ▶ } elsif ( ($x eq '-') or ($y eq '-') ) {
Condition100%3/3
$x eq "-" or $y eq "-"
l!l&&r!l&&!r
454537
MC/DC100%2/2
$x eq "-" or $y eq "-"
$x eq "-" $y eq "-"
Truth table100%3/3
A or B
A= $x eq "-"B= $y eq "-"
ABresult
1X1
011
000
71 90 $value = $refc->[1]; # cost for insertion/deletion operation
72 } else {
73 37 my $yግዕዝ = setForm ( $y, $ግዕዝ );
74  
75 37 my $yEquiv = Regexp::Ethiopic::Amharic::getRe ( "[=$yግዕዝ=]" );
76 37 my $yFamily = Regexp::Ethiopic::Amharic::getRe ( "[#$yግዕዝ#]" );
77  
78 # print " $yግዕዝ: $yEquiv / $yFamily\n";
79 # print "yEquiv/yFamily: <$yEquiv><$yFamily>\n";
80  
81 37 ▶ if ( $x =~ /$yFamily/ ) { # x & y are in the same family
Branch: 3 branches
BranchTrueFalseTotal
if ($x =~ /$yFamily/) { } 0 37 37
elsif (getForm($x) == getForm($y)) { } 22 15 37
elsif ($yEquiv and $x =~ /$yEquiv/) { } 0 15 15
82 0 ▶ if ( $yEquiv && $x =~ /$yEquiv/ ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($yEquiv and $x =~ /$yEquiv/) { } 0 0 0
elsif ($x =~ /[\x{12c9}\x{12cd}]/ and $y =~ /[\x{12c9}\x{12cd}]/) { } 0 0 0
elsif (getForm($x) > 7 or getForm($y) > 7) { } 0 0 0
Condition0%0/3
$yEquiv and $x =~ /$yEquiv/
!ll&&!rl&&r
000
MC/DC0%0/2
$yEquiv and $x =~ /$yEquiv/
$yEquiv $x =~ /$yEquiv/
Truth table0%0/3
A and B
A= $yEquivB= $x =~ /$yEquiv/
ABresult
0X0
100
111
83 0 $value = $refc->[3]; # phono/glyph equivalence: ኮ/ኰ, ቁ/ቍ
84 }
85 ▶ elsif ( ($x =~ /[ዉው]/) && ($y =~ /[ዉው]/) ) {
Condition0%0/3
$x =~ /[\x{12c9}\x{12cd}]/ and $y =~ /[\x{12c9}\x{12cd}]/
!ll&&!rl&&r
000
MC/DC0%0/2
$x =~ /[\x{12c9}\x{12cd}]/ and $y =~ /[\x{12c9}\x{12cd}]/
$x =~ /[\x{12c9}\x{12cd}]/ $y =~ /[\x{12c9}\x{12cd}]/
Truth table0%0/3
A and B
A= $x =~ /[\x{12c9}\x{12cd}]/B= $y =~ /[\x{12c9}\x{12cd}]/
ABresult
0X0
100
111
86 0 $value = $refc->[3]; #
87 }
88 ▶ elsif ( (getForm($x) > 7) || (getForm($y) > 7) ) {
Condition0%0/3
getForm($x) > 7 or getForm($y) > 7
l!l&&r!l&&!r
000
MC/DC0%0/2
getForm($x) > 7 or getForm($y) > 7
getForm($x) > 7 getForm($y) > 7
Truth table0%0/3
A or B
A= getForm($x) > 7B= getForm($y) > 7
ABresult
1X1
011
000
89 0 $value = $refc->[4]; # labiovelar mismatch
90 }
91 else {
92 0 $value = $refc->[5]; # form mismatch
93 }
94 } elsif ( getForm($x) == getForm($y) ) { # right form, wrong family
95 22 ▶ if ( $yEquiv && $x =~ /$yEquiv/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($yEquiv and $x =~ /$yEquiv/) { } 5 17 22
Condition66%2/3
$yEquiv and $x =~ /$yEquiv/
!ll&&!rl&&r
0175
MC/DC50%1/2
$yEquiv and $x =~ /$yEquiv/
$yEquiv $x =~ /$yEquiv/
Truth table66%2/3
A and B
A= $yEquivB= $x =~ /$yEquiv/
ABresult
0X0
100
111
96 5 $value = $refc->[6]; # phono/glyph equivalence: ሳ/ሣ
97 }
98 else {
99 17 my $xሳድስ = setForm ( $x, $ሳድስ );
100 17 my $yሳድስ = setForm ( $y, $ሳድስ );
101 17 ▶ if ( $IMCapsEquivalence{$xሳድስ} eq $yሳድስ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($IMCapsEquivalence{$xሳድስ} eq $yሳድስ) { } 0 17 17
102 0 $value = $refc->[7]; # finger slipped on shift key: ት/ጥ
103 }
104 else {
105 17 $value = $refc->[8]; # family mismatch
106 }
107 }
108 ▶ } elsif ( $yEquiv && $x =~ /$yEquiv/ ) { # different family, differnt form but related: ሀ/ሐ/ኀ/ሃ/ሓ/ኃ/ኻ
Condition33%1/3
$yEquiv and $x =~ /$yEquiv/
!ll&&!rl&&r
0150
MC/DC0%0/2
$yEquiv and $x =~ /$yEquiv/
$yEquiv $x =~ /$yEquiv/
Truth table33%1/3
A and B
A= $yEquivB= $x =~ /$yEquiv/
ABresult
0X0
100
111
109 0 $value = $refc->[9];
110 } else {
111 15 $value = $refc->[2]; # cost for letter mismatch
112 }
113 }
114  
115 # print "Comparing: $x/$y => $value\n";
116 135 $value;
117 }
118  
119  
120 #########################################################
121 # Do not change this, Do not put anything below this.
122 # File must return "true" value at termination
123 1 1;
124 ##########################################################
125  
126 __END__
↑ Summary