File Coverage

blib/lib/Lingua/AR/Abgad.pm
Criterion Covered Total %
statement 28 28 100.0
branch 4 4 100.0
condition n/a
subroutine 6 6 100.0
pod 2 2 100.0
total 40 40 100.0


line stmt bran cond sub pod time code
1             package Lingua::AR::Abgad;
2              
3 2     2   27623 use warnings;
  2         4  
  2         74  
4 2     2   12 use strict;
  2         4  
  2         67  
5 2     2   1016 use utf8;
  2         18  
  2         13  
6              
7 2     2   63 use base 'Exporter';
  2         3  
  2         2115  
8             our @EXPORT_OK = qw(kabeer sagheer);
9            
10             =head1 NAME
11              
12             Lingua::AR::Abgad
13              
14             =head1 VERSION
15              
16             Version 0.01
17              
18             =cut
19              
20             our $VERSION = '0.01';
21              
22              
23             =head1 SYNOPSIS
24              
25             The Abjad numerals are a decimal numeral system in which the 28 letters of
26             the Arabic alphabet are assigned numerical values. They are used today in many
27             fields especially poetry.For example, some words when calculated will give a
28             certain number representing an event. We have two Abjads one is called Kabeer(Big)
29             and the other is called Sagheer (small).
30              
31              
32             use Lingua::AR::Abgad qw(kabeer sagheer);
33             use utf8;
34             #returns numerical sum of all the chars in the string
35              
36             my $result = kabeer("Arabic string");
37             my $result = sagheer("Arabic string");
38            
39              
40              
41              
42             =head1 SUBROUTINES
43              
44             =head2 kabeer (Abjad Hawaz)
45              
46             =cut
47              
48             sub kabeer {
49 2     2 1 762 my $string = shift;
50 2         44 my %freq = (
51             "ا" => 1,
52             "آ" => 1,
53             "أ" => 1,
54             "ء" => 1,
55             "ب" => 2,
56             "ج" => 3,
57             "د" => 4,
58             "ه" => 5,
59             "ة" => 5,
60             "و" => 6,
61             "ؤ" => 6,
62             "ز" => 7,
63             "ح" => 8,
64             "ط" => 9,
65             "ي" => 10,
66             "ى" => 10,
67             "ئ" => 10,
68             "ك" => 20,
69             "ل" => 30,
70             "م" => 40,
71             "ن" => 50,
72             "س" => 60,
73             "ع" => 70,
74             "ف" => 80,
75             "ص" => 90,
76             "ق" => 100,
77             "ر" => 200,
78             "ش" => 300,
79             "ت" => 400,
80             "ث" => 500,
81             "خ" => 600,
82             "ذ" => 700,
83             "ض" => 800,
84             "ظ" => 900,
85             "غ" => 1000,
86             );
87              
88 2         2 my $string_sum = 0;
89 2         9 for ( split '', $string ) {
90 15 100       22 if ( exists $freq{$_} ) {
91 14         23 $string_sum += $freq{$_};
92             }
93             else {
94 1         3 $freq{$_} += 0;
95             }
96             }
97 2         18 return $string_sum;
98             }
99              
100             =head2 sagheer (Modern Alphabet order)
101              
102             =cut
103              
104             sub sagheer {
105 2     2 1 4 my $string = shift;
106 2         32 my %freq = (
107             "ا" => 1,
108             "آ" => 1,
109             "أ" => 1,
110             "ء" => 1,
111             "ب" => 2,
112             "ت" => 3,
113             "ث" => 4,
114             "ج" => 5,
115             "ح" => 6,
116             "خ" => 7,
117             "د" => 8,
118             "ذ" => 9,
119             "ر" => 10,
120             "ز" => 11,
121             "س" => 12,
122             "ش" => 13,
123             "ص" => 14,
124             "ض" => 15,
125             "ط" => 16,
126             "ظ" => 17,
127             "ع" => 18,
128             "غ" => 19,
129             "ف" => 20,
130             "ق" => 21,
131             "ك" => 22,
132             "ل" => 23,
133             "م" => 24,
134             "ن" => 25,
135             "ه" => 26,
136             "ة" => 26,
137             "و" => 27,
138             "ؤ" => 27,
139             "ي" => 28,
140             "ى" => 28,
141             "ئ" => 28,
142             );
143 2         2 my $string_sum = 0;
144 2         7 for ( split '', $string ) {
145 7 100       16 if ( exists $freq{$_} ) {
146 3         5 $string_sum += $freq{$_};
147             }
148             else {
149 4         7 $freq{$_} += 0;
150             }
151             }
152 2         18 return $string_sum;
153             }
154              
155              
156             =head1 AUTHOR
157              
158             Moosa, C<< >>
159              
160             =head1 BUGS
161              
162             Please report any bugs or feature requests to C, or through
163             the web interface at L. I will be notified, and then you'll
164             automatically be notified of progress on your bug as I make changes.
165              
166              
167              
168              
169             =head1 SUPPORT
170              
171             You can find documentation for this module with the perldoc command.
172              
173             perldoc Lingua::AR::Abgad
174              
175              
176             You can also look for information at:
177              
178             =over 4
179              
180             =item * RT: CPAN's request tracker
181              
182             L
183              
184             =item * AnnoCPAN: Annotated CPAN documentation
185              
186             L
187              
188             =item * CPAN Ratings
189              
190             L
191              
192             =item * Search CPAN
193              
194             L
195              
196             =back
197              
198              
199             =head1 ACKNOWLEDGEMENTS
200              
201              
202             =head1 LICENSE AND COPYRIGHT
203              
204             Copyright 2012 Moosa.
205              
206             This program is free software; you can redistribute it and/or modify it
207             under the terms of either: the GNU General Public License as published
208             by the Free Software Foundation; or the Artistic License.
209              
210             See http://dev.perl.org/licenses/ for more information.
211              
212              
213             =cut
214              
215             1; # End of Lingua::AR::Abgad