| 1 | package Convert::CEGH::Transliterate; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Regexp::Ethiopic qw(:forms setForm); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | BEGIN | ||||||||||||||||||||||||||||
| 8 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use base qw( Exporter ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use vars qw( $COPTIC @EXPORT_OK $VERSION ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | @EXPORT_OK = qw( transliterate ); | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | $VERSION = "0.07"; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 1 | $COPTIC = qr/[ϚCϢϤϦϨϬϮϪ]/; | |||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | sub fromIPA | ||||||||||||||||||||||||||||
| 21 | 4 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
fromIPA: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 22 | 4 | my ($string, $script) = @_; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 4 | $_ = $string; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 4 | ▶ | if ( $script =~ /^et/ ) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 27 | 1 | tr/ʤʧΘv/ztzb/; | |||||||||||||||||||||||||||
| 28 | 1 | s/k'/q/g; | |||||||||||||||||||||||||||
| 29 | 1 | s/p'/P/g; | |||||||||||||||||||||||||||
| 30 | 1 | s/s'/S/g; | |||||||||||||||||||||||||||
| 31 | 1 | s/t'/T/g; | |||||||||||||||||||||||||||
| 32 | 1 | s/d'/D/g; | |||||||||||||||||||||||||||
| 33 | 1 | tr/abgdhwzħTjklmnsʕfSqrʃtξDPp/አበገደሀወዘሐጠየከለመነሠዐፈጸቀረሰተኀፀጰፐ/; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | elsif ( $script =~ /^he/ ) { | ||||||||||||||||||||||||||||
| 36 | 1 | tr/xfʤʧv/kpztb/; | |||||||||||||||||||||||||||
| 37 | 1 | s/k'/q/g; | |||||||||||||||||||||||||||
| 38 | 1 | s/s'/S/g; | |||||||||||||||||||||||||||
| 39 | 1 | s/d'/d/g; | |||||||||||||||||||||||||||
| 40 | 1 | s/p'/p/g; | |||||||||||||||||||||||||||
| 41 | 1 | s/t'/t/g; | |||||||||||||||||||||||||||
| 42 | 1 | s/ξ/h/g; | |||||||||||||||||||||||||||
| 43 | 1 | tr/abgdhwzħΘjklmnsʕpSqrʃt/אבגדהוזחטיכלמנסעפצקרשת/; | |||||||||||||||||||||||||||
| 44 | 1 | $_ = scalar reverse ( $_ ); | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | ▶ | elsif ( $script =~ /^el/ || $script =~ /^co/ ) { | |||||||||||||||||||||||||||
|
Condition66%2/3
$script =~ /^el/ or $script =~ /^co/
MC/DC0%0/2
$script =~ /^el/ or $script =~ /^co/
$script =~ /^el/
$script =~ /^co/
Truth table66%2/3
A or B
A= $script =~ /^el/B= $script =~ /^co/
| |||||||||||||||||||||||||||||
| 47 | 2 | tr/ʤʧʕwv/ztabb/; | |||||||||||||||||||||||||||
| 48 | 2 | s/ps/P/g; | |||||||||||||||||||||||||||
| 49 | 2 | s/d'/d/g; | |||||||||||||||||||||||||||
| 50 | 2 | s/p'/p/g; | |||||||||||||||||||||||||||
| 51 | 2 | s/t'/t/g; | |||||||||||||||||||||||||||
| 52 | 2 | s/ξ/h/g; | |||||||||||||||||||||||||||
| 53 | 2 | tr/abgdazaΘaklmnxaprstafʧPa/ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΧΨΩ/; | |||||||||||||||||||||||||||
| 54 | # | ||||||||||||||||||||||||||||
| 55 | # this is broken, the coptic extras are missing | ||||||||||||||||||||||||||||
| 56 | # and greek isn't mapping the extras, what is "w" is greek? | ||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | $_ | ||||||||||||||||||||||||||||
| 60 | 4 | } | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | sub toIPA | ||||||||||||||||||||||||||||
| 64 | 4 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
toIPA: called CC=6 SCAR=25.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 4 | $_ = $_[0]; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 4 | ▶ | if ( /$COPTIC/ || /\p{Greek}/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
/$Convert::CEGH::Transliterate::COPTIC/ or /\p{Greek}/
MC/DC0%0/2
/$Convert::CEGH::Transliterate::COPTIC/ or /\p{Greek}/
/$Convert::CEGH::Transliterate::COPTIC/
/\p{Greek}/
Truth table33%1/3
A or B
A= /$Convert::CEGH::Transliterate::COPTIC/B= /\p{Greek}/
| |||||||||||||||||||||||||||||
| 69 | 0 | $_ = uc($_); | |||||||||||||||||||||||||||
| 70 | 0 | tr/ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ/abgdazaΘaklmnKaprstafxPa/; | |||||||||||||||||||||||||||
| 71 | 0 | ▶ | if ( /$COPTIC/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 0 | tr/ϚCϢϤϦϨϪϬ/ssʃfxhʤʧ/; | |||||||||||||||||||||||||||
| 73 | 0 | s/Ϯ/t/g; # really "ti" but we ignore the vowel. | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | 0 | s/[ϚϜ]/w/g; | |||||||||||||||||||||||||||
| 76 | 0 | s/[ϘϞ]/k'/g; | |||||||||||||||||||||||||||
| 77 | 0 | s/K/kh/g; | |||||||||||||||||||||||||||
| 78 | 0 | s/P/ps/g; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | 4 | ▶ | if ( /\p{Ethiopic}/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 4 | s/(.)/setForm($1,$ግዕዝ)/eg; | |||||||||||||||||||||||||||
| 82 | 4 | tr/አበገደሀወዘሐጠየከለመነሠዐፈጸቀረሰተኀፀጰፐ/abgdhwzħTjklmnsʕfSqrʃtξDPp/; | |||||||||||||||||||||||||||
| 83 | # | ||||||||||||||||||||||||||||
| 84 | # convert placeholder symbols to multiple symbols: | ||||||||||||||||||||||||||||
| 85 | # | ||||||||||||||||||||||||||||
| 86 | 4 | s/q/k'/g; | |||||||||||||||||||||||||||
| 87 | 4 | s/P/p'/g; | |||||||||||||||||||||||||||
| 88 | 4 | s/S/s'/g; | |||||||||||||||||||||||||||
| 89 | 4 | s/T/t'/g; | |||||||||||||||||||||||||||
| 90 | 4 | s/C/ʧ'/g; | |||||||||||||||||||||||||||
| 91 | 4 | s/D/d'/g; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | 4 | ▶ | if ( /\p{Hebrew}/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | 0 | $_ = scalar reverse ( $_ ); | |||||||||||||||||||||||||||
| 95 | # | ||||||||||||||||||||||||||||
| 96 | # map finals to initials/medials: | ||||||||||||||||||||||||||||
| 97 | # | ||||||||||||||||||||||||||||
| 98 | 0 | s/ך/כ/g; | |||||||||||||||||||||||||||
| 99 | 0 | s/ץ/צ/g; | |||||||||||||||||||||||||||
| 100 | 0 | s/ף/פ/g; | |||||||||||||||||||||||||||
| 101 | 0 | s/ם/מ/g; | |||||||||||||||||||||||||||
| 102 | 0 | s/ן/נ/g; | |||||||||||||||||||||||||||
| 103 | 0 | tr/אבגדהוזחטיכלמנסעפצקרשת/abgdhwzħΘjklmnsʕpSqrʃt/; | |||||||||||||||||||||||||||
| 104 | # | ||||||||||||||||||||||||||||
| 105 | # convert placeholder symbols to multiple symbols: | ||||||||||||||||||||||||||||
| 106 | # | ||||||||||||||||||||||||||||
| 107 | 0 | s/q/k'/; | |||||||||||||||||||||||||||
| 108 | 0 | s/S/s'/; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | 4 | s/(.)a/$1/g; # strip vowels except first | |||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 4 | $_; | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | sub transliterate | ||||||||||||||||||||||||||||
| 117 | 4 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
transliterate: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 118 | 4 | my ( $to, @strings ) = @_; | |||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 4 | my ( @trans ) = (); | |||||||||||||||||||||||||||
| 121 | 4 | foreach ( @strings ) { | |||||||||||||||||||||||||||
| 122 | 4 | push ( @trans, fromIPA ( toIPA ( $_ ), $to ) ); | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 4 | ▶ | ( wantarray ) ? @trans : $trans[0] ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | ######################################################### | ||||||||||||||||||||||||||||
| 130 | # Do not change this, Do not put anything below this. | ||||||||||||||||||||||||||||
| 131 | # File must return "true" value at termination | ||||||||||||||||||||||||||||
| 132 | 1 | 1; | |||||||||||||||||||||||||||
| 133 | ########################################################## | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | __END__ | ||||||||||||||||||||||||||||