| 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
| |||||||||||||||||||||||||||||||||||||
| 69 | 8 | $value = $refc->[0]; # cost for letter match | |||||||||||||||||||||||||||||||||||
| 70 | ▶ | } elsif ( ($x eq '-') or ($y eq '-') ) { | |||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$x eq "-" or $y eq "-"
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 "-"
| |||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if ( $yEquiv && $x =~ /$yEquiv/ ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
$yEquiv and $x =~ /$yEquiv/
MC/DC0%0/2
$yEquiv and $x =~ /$yEquiv/
$yEquiv
$x =~ /$yEquiv/
Truth table0%0/3
A and B
A= $yEquivB= $x =~ /$yEquiv/
| |||||||||||||||||||||||||||||||||||||
| 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}]/
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}]/
| |||||||||||||||||||||||||||||||||||||
| 86 | 0 | $value = $refc->[3]; # | |||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||
| 88 | ▶ | elsif ( (getForm($x) > 7) || (getForm($y) > 7) ) { | |||||||||||||||||||||||||||||||||||
|
Condition0%0/3
getForm($x) > 7 or getForm($y) > 7
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
| |||||||||||||||||||||||||||||||||||||
| 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
Condition66%2/3
$yEquiv and $x =~ /$yEquiv/
MC/DC50%1/2
$yEquiv and $x =~ /$yEquiv/
$yEquiv
$x =~ /$yEquiv/
Truth table66%2/3
A and B
A= $yEquivB= $x =~ /$yEquiv/
| |||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||
| 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/
MC/DC0%0/2
$yEquiv and $x =~ /$yEquiv/
$yEquiv
$x =~ /$yEquiv/
Truth table33%1/3
A and B
A= $yEquivB= $x =~ /$yEquiv/
| |||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||