| 1 | # Used to translate roman key board strokes to Unicode. | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | package Unicode::Indic::Phonetic; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | our $VERSION = 0.01; | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 0 | my $proto = shift; | |||||||||||||||||||||||||||||||||||||||||
| 9 | 0 | ▶ | my $class = ref($proto)||$proto; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 0 | my $self = { | |||||||||||||||||||||||||||||||||||||||||
| 11 | @_ | ||||||||||||||||||||||||||||||||||||||||||
| 12 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | sub translate{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
translate: called CC=27 SCAR=46.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | my $map = $self ->{Map}; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | my $text = shift; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | my $prev = ''; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | my $boc = 1; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | my $out; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | my $flag = ''; | |||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | my $halant = $map->{virama}; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | foreach my $ch (split (//, $text),' '){ | |||||||||||||||||||||||||||||||||||||||||
| 25 | 36 | ▶ | if ($flag ne ''){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | $flag = '' if ($flag eq '<' && $ch eq '>'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$flag eq "<" and $ch eq ">"
MC/DC0%0/2
$flag eq "<" and $ch eq ">"
$flag eq "<"
$ch eq ">"
Truth table0%0/3
A and B
A= $flag eq "<"B= $ch eq ">"
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | $flag = '' if ($flag eq '&' && $ch eq ';'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$flag eq "&" and $ch eq ";"
MC/DC0%0/2
$flag eq "&" and $ch eq ";"
$flag eq "&"
$ch eq ";"
Truth table0%0/3
A and B
A= $flag eq "&"B= $ch eq ";"
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | if ($flag eq '#' && $ch eq '#'){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$flag eq "#" and $ch eq "#"
MC/DC0%0/2
$flag eq "#" and $ch eq "#"
$flag eq "#"
$ch eq "#"
Truth table0%0/3
A and B
A= $flag eq "#"B= $ch eq "#"
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | $flag = ''; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | $out .= '\e'; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | if ($flag ne ''){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | $out .= $ch unless $ch eq '#'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | $out .= '\e' if $ch eq '#'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 36 | ▶ | if (!$prev){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 5 | $prev = $ch; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 5 | next; | |||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 31 | ▶ | $out .= $halant if (!$boc && $prev !~ /[aeiouAEIOUMHR]/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$boc or $prev =~ /[aeiouAEIOUMHR]/
MC/DC100%2/2
$boc or $prev =~ /[aeiouAEIOUMHR]/
$boc
$prev =~ /[aeiouAEIOUMHR]/
Truth table100%3/3
A or B
A= $bocB= $prev =~ /[aeiouAEIOUMHR]/
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 31 | ▶ | if (exists $map->{$prev.$ch}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 4 | ▶ | if ($boc && $ch =~ /[aieouAEIOUMHR]/){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$boc and $ch =~ /[aieouAEIOUMHR]/
MC/DC0%0/2
$boc and $ch =~ /[aieouAEIOUMHR]/
$boc
$ch =~ /[aieouAEIOUMHR]/
Truth table33%1/3
A and B
A= $bocB= $ch =~ /[aieouAEIOUMHR]/
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $out .= $map->{'_'.$prev.$ch}; | |||||||||||||||||||||||||||||||||||||||||
| 47 | }else{ | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 4 | $out .= $map->{$prev.$ch}; | |||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 4 | $prev =''; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 4 | $boc = ($ch =~ /[aieouAEIOUMHR]/); | |||||||||||||||||||||||||||||||||||||||||
| 52 | }elsif (exists $map->{$prev}){ | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 23 | ▶ | if ($boc && $prev =~ /[aieouAEIOUR]/){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$boc and $prev =~ /[aieouAEIOUR]/
MC/DC0%0/2
$boc and $prev =~ /[aieouAEIOUR]/
$boc
$prev =~ /[aieouAEIOUR]/
Truth table66%2/3
A and B
A= $bocB= $prev =~ /[aieouAEIOUR]/
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | $out .= $map->{'_'.$prev}; | |||||||||||||||||||||||||||||||||||||||||
| 55 | }else{ | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 23 | ▶ | $out .= $map->{$prev} if $map->{$prev}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 23 | $boc = ($prev =~ /[aieouAEIOUMHR]/); | |||||||||||||||||||||||||||||||||||||||||
| 59 | 23 | $prev = $ch; | |||||||||||||||||||||||||||||||||||||||||
| 60 | }else{ | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 4 | ▶ | $out .= $prev unless $prev eq '#'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 4 | ▶ | $out .= '\e' if $prev eq '#'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 4 | $boc = 1; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 4 | ▶ | if ((($prev eq '&') || ($prev eq '<'))|| ($prev eq '#')){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$prev eq "&" or $prev eq "<" or $prev eq "#"
$prev eq "&" or $prev eq "<"
MC/DC0%0/3
$prev eq "&" or $prev eq "<" or $prev eq "#"
$prev eq "&"
$prev eq "<"
$prev eq "#"
Truth table25%1/4
A or B or C
A= $prev eq "&"B= $prev eq "<"C= $prev eq "#"
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $flag = $prev; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $out .= $ch; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | $prev = ''; | |||||||||||||||||||||||||||||||||||||||||
| 68 | }else{ | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 4 | $prev = $ch; | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | sub romanise{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
romanise: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my $map = $self ->{Map}; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | $self->{RMap} = $self->rmap() unless exists $self->{RMap}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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 | ▶ | if (ord($ch) >= $base){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | my $ch1 .= $rmap->[ord($ch) - $base]; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | if ($ch eq $halant){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $prev = 'a'; | |||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | $out .= 'a' if "$prev.$ch1" !~ /[aeiouAEIOUMHR]/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $out .= $ch1; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $prev = $ch1; | |||||||||||||||||||||||||||||||||||||||||
| 96 | }else{ | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | $out .= 'a' if $prev !~ /[aeiouAEIOUMHR]/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | $out .= '#' if $ch eq '\e'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | $out .= $ch; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $prev = 'a'; | |||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub rmap{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rmap: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 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}){ | |||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my $v = ord($Map->{$key}) - $base; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | next if $v < 0 or length $key > 3; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$v < 0 or length $key > 3
MC/DC0%0/2
$v < 0 or length $key > 3
$v < 0
length $key > 3
Truth table0%0/3
A or B
A= $v < 0B= 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 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | __END__ | ||||||||||||||||||||||||||||||||||||||||||