line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
883294
|
use strict; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
148
|
|
2
|
5
|
|
|
5
|
|
21
|
use warnings; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
295
|
|
3
|
|
|
|
|
|
|
package Lingua::AR::Tashkeel; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: Subroutines for operating on Arabic vowel marks |
6
|
|
|
|
|
|
|
our $VERSION = '0.004'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
18
|
use Exporter 'import'; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
212
|
|
9
|
|
|
|
|
|
|
our @EXPORT_OK = qw(strip prune fix); |
10
|
5
|
|
|
5
|
|
19
|
use Carp; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
292
|
|
11
|
5
|
|
|
5
|
|
2519
|
use charnames ':full'; |
|
5
|
|
|
|
|
128772
|
|
|
5
|
|
|
|
|
27
|
|
12
|
5
|
|
|
5
|
|
1454
|
use Unicode::Normalize; |
|
5
|
|
|
|
|
157322
|
|
|
5
|
|
|
|
|
434
|
|
13
|
5
|
|
|
5
|
|
31
|
use utf8; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
29
|
|
14
|
5
|
|
|
5
|
|
2444
|
use Lingua::AR::Regexp; |
|
5
|
|
|
|
|
7582
|
|
|
5
|
|
|
|
|
129
|
|
15
|
5
|
|
|
5
|
|
23
|
use Regexp::CharClasses::Helper; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
319
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=pod |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=encoding utf8 |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 NAME |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Lingua::AR::Tashkeel - Subroutines for handling Arabic Vowels and Vowel marks |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 SYNOPSIS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use Lingua::AR::Tashkeel qw(strip prune fix); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Strip all short vowels |
32
|
|
|
|
|
|
|
strip('مَكَرُونَة'); # => مكرونة |
33
|
|
|
|
|
|
|
# Heuristic for removing short vowels without causing ambiguity |
34
|
|
|
|
|
|
|
prune('فَتَّة'); # => فتّة |
35
|
|
|
|
|
|
|
# Heuristic for fixing mixed up short and long vowels |
36
|
|
|
|
|
|
|
fix('ماحشي'); # => مَحشي |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 DESCRIPTION |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Subroutines for working with Arabic long (حروف علة) and short vowels (حركات تشكيل) |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 METHODS AND ARGUMENTS |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=over 4 |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item strip($string) |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Strips away all Arabic short vowels (Tashkeel). |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub strip { |
54
|
35
|
|
|
35
|
1
|
11432
|
my $string = NFD shift; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
#$string =~ s/(?[ (\p{InArabic} & \p{Mn}) - \N{ARABIC HAMZA ABOVE} ])//g; |
57
|
35
|
|
|
|
|
1506
|
$string =~ s/\p{Lingua::AR::Regexp::IsTashkeel}//gx; |
58
|
|
|
|
|
|
|
|
59
|
35
|
|
|
|
|
73
|
return NFC $string; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item prune($string) |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Heuristic for pruning the short vowels that a native speaker wouldn't write, |
65
|
|
|
|
|
|
|
as leaving them out wouldn't introduce ambiguity. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
This is often preferable to strip, as Shaddas, or Dammas that indicate a passive verb are useful clues that one might want to keep. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub InOnesToKeepIn { |
72
|
5
|
|
|
5
|
0
|
51811
|
return Regexp::CharClasses::Helper::fmt( |
73
|
|
|
|
|
|
|
'+Lingua::AR::Regexp::IsTashkeel', |
74
|
|
|
|
|
|
|
'-ARABIC SHADDA', |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub prune { |
79
|
5
|
|
|
5
|
1
|
2019
|
my $string = NFD shift; |
80
|
|
|
|
|
|
|
|
81
|
5
|
|
|
|
|
260
|
$string =~ s/\p{Lingua::AR::Tashkeel::InOnesToKeepIn}//g; |
82
|
|
|
|
|
|
|
|
83
|
5
|
|
|
|
|
13
|
return NFC $string; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item fix($string) |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Transliterating from a romanized representation of Arabic to actual Arabic script often gives incorrect results regarding short/long vowels. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This subroutine implements a heuristic for fixing such mix ups. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub fix { |
95
|
3
|
|
|
3
|
1
|
976
|
my $string = NFD shift; |
96
|
|
|
|
|
|
|
|
97
|
3
|
|
|
|
|
173
|
return $string; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
__END__ |