line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lingua::Stem::UniNE::FA; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
49528
|
use v5.8.1; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
106
|
|
4
|
2
|
|
|
2
|
|
12
|
use utf8; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
25
|
|
5
|
2
|
|
|
2
|
|
46
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
69
|
|
6
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
76
|
|
7
|
2
|
|
|
2
|
|
1015
|
use parent 'Exporter'; |
|
2
|
|
|
|
|
339
|
|
|
2
|
|
|
|
|
12
|
|
8
|
2
|
|
|
2
|
|
947
|
use Unicode::CaseFold qw( fc ); |
|
2
|
|
|
|
|
1193
|
|
|
2
|
|
|
|
|
141
|
|
9
|
2
|
|
|
2
|
|
1256
|
use Unicode::Normalize qw( NFC ); |
|
2
|
|
|
|
|
3515
|
|
|
2
|
|
|
|
|
218
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
BEGIN { # Perl v5.16.0 workaround for RT#113750 |
12
|
2
|
|
|
2
|
|
6
|
local $_; |
13
|
2
|
|
|
|
|
2090
|
require charnames; |
14
|
2
|
|
|
|
|
62811
|
charnames->import(':full'); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
18
|
|
|
|
|
|
|
our @EXPORT_OK = qw( stem stem_fa ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
*stem_fa = \&stem; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub stem { |
23
|
43
|
|
|
43
|
0
|
606
|
my ($word) = @_; |
24
|
|
|
|
|
|
|
|
25
|
43
|
|
|
|
|
148
|
$word = NFC fc $word; |
26
|
43
|
|
|
|
|
8218
|
$word = remove_kasra($word); |
27
|
43
|
|
|
|
|
89
|
$word = remove_suffix($word); |
28
|
43
|
|
|
|
|
91
|
$word = remove_kasra($word); |
29
|
|
|
|
|
|
|
|
30
|
43
|
|
|
|
|
186
|
return $word; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub remove_kasra { |
34
|
86
|
|
|
86
|
0
|
124
|
my ($word) = @_; |
35
|
|
|
|
|
|
|
|
36
|
86
|
100
|
|
|
|
279
|
return $word |
37
|
|
|
|
|
|
|
if length $word < 5; |
38
|
|
|
|
|
|
|
|
39
|
46
|
|
|
|
|
87
|
$word =~ s{ \N{ARABIC KASRA} $}{}x; |
40
|
|
|
|
|
|
|
|
41
|
46
|
|
|
|
|
98
|
return $word; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub remove_suffix { |
45
|
43
|
|
|
43
|
0
|
55
|
my ($word) = @_; |
46
|
43
|
|
|
|
|
65
|
my $length = length $word; |
47
|
|
|
|
|
|
|
|
48
|
43
|
100
|
|
|
|
92
|
if ($length > 7) { |
49
|
20
|
100
|
|
|
|
157
|
return $word |
50
|
|
|
|
|
|
|
if $word =~ s{ (?: |
51
|
|
|
|
|
|
|
آباد | باره | بندی | بندي | ترین | ترين | ریزی | |
52
|
|
|
|
|
|
|
ريزي | سازی | سازي | گیری | گيري | هایی | هايي |
53
|
|
|
|
|
|
|
) $}{}x; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
30
|
100
|
|
|
|
59
|
if ($length > 6) { |
57
|
14
|
100
|
|
|
|
85
|
return $word |
58
|
|
|
|
|
|
|
if $word =~ s{ (?: |
59
|
|
|
|
|
|
|
اند | ایم | ايم | شان | های | هاي |
60
|
|
|
|
|
|
|
) $}{}x; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
24
|
100
|
|
|
|
53
|
if ($length > 5) { |
64
|
18
|
100
|
|
|
|
88
|
return normalize($word) |
65
|
|
|
|
|
|
|
if $word =~ s{ ان $}{}x; |
66
|
|
|
|
|
|
|
|
67
|
10
|
100
|
|
|
|
79
|
return $word |
68
|
|
|
|
|
|
|
if $word =~ s{ (?: |
69
|
|
|
|
|
|
|
ات | اش | ام | تر | را | ون | ها | هء | ین | ين |
70
|
|
|
|
|
|
|
) $}{}x; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
7
|
50
|
|
|
|
18
|
if ($length > 3) { |
74
|
7
|
50
|
|
|
|
63
|
return $word |
75
|
|
|
|
|
|
|
if $word =~ s{ (?: ت | ش | م | ه | ی | ي ) $}{}x; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
0
|
return $word; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub normalize { |
82
|
8
|
|
|
8
|
0
|
10
|
my ($word) = @_; |
83
|
|
|
|
|
|
|
|
84
|
8
|
50
|
|
|
|
24
|
return $word |
85
|
|
|
|
|
|
|
if length $word < 4; |
86
|
|
|
|
|
|
|
|
87
|
8
|
50
|
|
|
|
49
|
if ($word =~ s{ (?: ت | ر | ش | گ | م | ى ) $}{}x) { |
88
|
8
|
100
|
|
|
|
23
|
return $word |
89
|
|
|
|
|
|
|
if length $word < 4; |
90
|
|
|
|
|
|
|
|
91
|
6
|
|
|
|
|
20
|
$word =~ s{ (?: ی | ي ) $}{}x; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
6
|
|
|
|
|
21
|
return $word; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |