File Coverage

blib/lib/Lingua/AR/Word/Encode.pm
Criterion Covered Total %
statement 91 91 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod 0 1 0.0
total 94 95 98.9


line stmt bran cond sub pod time code
1             package Lingua::AR::Word;
2              
3 1     1   6 use strict;
  1         2  
  1         38  
4 1     1   6 use utf8;
  1         1  
  1         6  
5              
6              
7             sub encode{
8              
9 1     1 0 3 my $word=shift;
10              
11             # let's take away the FIRST hamza ON/UNDER the alef from the word
12 1         4 $word=~s/\x{0623}//; #HAMZA ON ALEF
13 1         2 $word=~s/\x{0625}//; #HAMZA UNDER ALEF
14              
15             # let's take away the double-letters (=letter+shadda)
16 1         2 $word=~s/\x{0628}\x{0651}/bb/g;
17 1         3 $word=~s/\x{062A}\x{0651}/tt/g;
18 1         3 $word=~s/\x{062B}\x{0651}/_t_t/g;
19 1         2 $word=~s/\x{062C}\x{0651}/^g^g/g;
20 1         2 $word=~s/\x{062D}\x{0651}/.h.h/g;
21 1         3 $word=~s/\x{062E}\x{0651}/_h_h/g;
22 1         3 $word=~s/\x{062F}\x{0651}/dd/g;
23 1         2 $word=~s/\x{0630}\x{0651}/_d_d/g;
24 1         3 $word=~s/\x{0632}\x{0651}/zz/g;
25 1         2 $word=~s/\x{0633}\x{0651}/ss/g;
26 1         3 $word=~s/\x{0634}\x{0651}/^s^s/g;
27 1         2 $word=~s/\x{0635}\x{0651}/.s.s/g;
28 1         3 $word=~s/\x{0636}\x{0651}/.d.d/g;
29 1         2 $word=~s/\x{0637}\x{0651}/.t.t/g;
30 1         2 $word=~s/\x{0638}\x{0651}/.z.z/g;
31 1         4 $word=~s/\x{0639}\x{0651}/``/g;
32 1         2 $word=~s/\x{063A}\x{0651}/.g.g/g;
33 1         2 $word=~s/\x{0641}\x{0651}/ff/g;
34 1         3 $word=~s/\x{0642}\x{0651}/qq/g;
35 1         2 $word=~s/\x{0643}\x{0651}/kk/g;
36 1         3 $word=~s/\x{0644}\x{0651}/ll/g;
37 1         32 $word=~s/\x{0645}\x{0651}/mm/g;
38 1         2 $word=~s/\x{0646}\x{0651}/nn/g;
39 1         4 $word=~s/\x{0647}\x{0651}/hh/g;
40 1         2 $word=~s/\x{0648}\x{0651}/ww/g;
41 1         3 $word=~s/\x{064A}\x{0651}/yy/g;
42 1         2 $word=~s/\x{0631}\x{0651}/rr/g;
43              
44             # now let's think of single letters
45 1         5 $word=~s/\x{0627}/A/g; #ALEF;
46 1         3 $word=~s/\x{062A}/t/g; #TEH;
47 1         2 $word=~s/\x{0643}/k/g; #KAF
48 1         2 $word=~s/\x{0628}/b/g; #BEH
49 1         4 $word=~s/\x{0642}/q/g; #QAF
50 1         2 $word=~s/\x{062E}/_h/g; #KHAH
51 1         2 $word=~s/\x{0629}/T/g; #TEH MARBUTA
52 1         2 $word=~s/\x{0631}/r/g; #REH
53 1         2 $word=~s/\x{062C}/^g/g; #JEEM
54 1         2 $word=~s/\x{0634}/^s/g; #SHEEN
55 1         2 $word=~s/\x{0633}/s/g; #SEEN
56 1         3 $word=~s/\x{0635}/.s/g; #SAD
57 1         2 $word=~s/\x{062F}/d/g; #DAL
58 1         2 $word=~s/\x{0630}/_d/g; #THAL
59 1         1 $word=~s/\x{062B}/_t/g; #THEH
60 1         2 $word=~s/\x{062D}/.h/g; #HAH
61 1         654 $word=~s/\x{0636}/.d/g; #DAD
62 1         4 $word=~s/\x{0641}/f/g; #FEH
63 1         2 $word=~s/\x{0632}/z/g; #ZAIN
64 1         2 $word=~s/\x{0637}/.t/g; #TAH
65 1         2 $word=~s/\x{0638}/.z/g; #ZAH
66 1         2 $word=~s/\x{063A}/.g/g; #GHAIN
67 1         5 $word=~s/\x{0644}/l/g; #LAM
68 1         6 $word=~s/\x{0645}/m/g; #MEEM
69 1         3 $word=~s/\x{0646}/n/g; #NOON
70 1         3 $word=~s/\x{0647}/h/g; #HEH
71 1         2 $word=~s/\x{0648}/w/g; #WAW
72 1         2 $word=~s/\x{0649}/_A/g; #ALEF MAKSURA
73 1         2 $word=~s/\x{067E}/p/g; #PEH
74 1         2 $word=~s/\x{06A4}/v/g; #VEH
75 1         2 $word=~s/\x{06AF}/g/g; #GAF
76             #$word=~s/\x{0681}/c/g; #HAMZA ON HAH
77 1         2 $word=~s/\x{0686}/^c/g; #HAH WITH MIDDLE 3 DOTS DOWNWARD
78             #$word=~s/\x{0695}/.r/g; #REH WITH SMALL V BELOW
79 1         2 $word=~s/\x{064B}/aN/g; #FATHATAN
80 1         2 $word=~s/\x{064C}/uN/g; #DAMMATAN
81 1         2 $word=~s/\x{064D}/iN/g; #KASRATAN
82 1         1 $word=~s/\x{064E}/a/g; #FATHA
83 1         2 $word=~s/\x{064F}/u/g; #DAMMA
84 1         2 $word=~s/\x{0650}/i/g; #KASRA
85 1         2 $word=~s/\x{0670}/_a/g; #LETTER SUPERSCRIPT ALEF = DAGGER ALIF
86             #$word=~s/\x{0657}/_u/g; #INVERTED DAMMA
87             #$word=~s/\x{0656}/_i/g; #SUBSCRIPT ALEF
88 1         3 $word=~s/\x{060C}/,/g; #COMMA
89 1         3 $word=~s/\x{061B}/;/g; #SEMICOLON
90 1         2 $word=~s/\x{061F}/?/g; #QUESTION MARK
91             #$word=~s/\x{0695}/'A/g; #REH WITH SMALL V BELOW
92 1         2 $word=~s/\x{0621}/'/g; #HAMZA
93 1         3 $word=~s/\x{0622}/'A/g; #MADDA ON ALEF
94 1         2 $word=~s/\x{0623}/'/g; #HAMZA ON ALEF
95 1         2 $word=~s/\x{0624}/'/g; #HAMZA ON WAW
96 1         2 $word=~s/\x{0625}/'/g; #HAMZA UNDER ALEF
97 1         3 $word=~s/\x{0626}/'/g; #HAMZA ON YEH
98 1         3 $word=~s/\x{0639}/`/g; #AIN
99 1         3 $word=~s/\x{0640}/--/g; #TATWEEL
100 1         2 $word=~s/\x{064A}/y/g; #YEH
101 1         1 $word=~s/\x{0652}//g; #SUKUN
102 1         3 $word=~s/\x{0671}/A/g; #ALIF WASLA
103             #$word=~s/\x{0685}/,c/g; #HAH WITH 3 DOTS ABOVE
104 1         2 $word=~s/\x{0698}/^z/g; #REH WITH 3 DOTS ABOVE = JEH
105             #$word=~s/\x{06AD}/^n/g; #KAF WITH 3 DOTS ABOVE = NG
106             #$word=~s/\x{06B5}/^l/g; #LAM WITH SMALL V
107 1         6 return $word;
108             }
109              
110             1;
111             __END__