UniNE/FA.pm

filter: Statementstmt 98.1% 54 / 55 Branchbran 84.6% 22 / 26 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 0.0% 0 / 4 totaltotal 90.7% 88 / 97 CC 14 SCAR 16.5
CC
14
Cov
94%
remove_suffix
10.1
normalize
4.1
remove_kasra
2.0
CRAP 5.2
« UniNE/BG.pm ↑ Summary UniNE/DE.pm »
1 package Lingua::Stem::UniNE::FA;
2  
3 2 ▶use v5.8.1;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Unicode::CaseFold qw( fc );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Unicode::Normalize qw( NFC );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶BEGIN { # Perl v5.16.0 workaround for RT#113750
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 local $_;
13 2 require charnames;
14 2 charnames->import(':full');
15 }
16  
17 2 our $VERSION = '0.08';
18 2 our @EXPORT_OK = qw( stem stem_fa );
19  
20 2 *stem_fa = \&stem;
21  
22 43 ▶sub stem {
Subroutine stem: called CC=1 SCAR=0.0
Pod undocumented
23 43 my ($word) = @_;
24  
25 43 $word = NFC fc $word;
26 43 $word = remove_kasra($word);
27 43 $word = remove_suffix($word);
28 43 $word = remove_kasra($word);
29  
30 43 return $word;
31 }
32  
33 86 ▶sub remove_kasra {
Subroutine remove_kasra: called CC=2 SCAR=6.9
Pod undocumented
34 86 my ($word) = @_;
35  
36 86 ▶ return $word
Branch: 1 branch
BranchTrueFalseTotal
if length $word < 5 40 46 86
37 if length $word < 5;
38  
39 46 $word =~ s{ \N{ARABIC KASRA} $}{}x;
40  
41 46 return $word;
42 }
43  
44 43 ▶sub remove_suffix {
Subroutine remove_suffix: called CC=10 SCAR=23.1
Pod undocumented
45 43 my ($word) = @_;
46 43 my $length = length $word;
47  
48 43 ▶ if ($length > 7) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > 7) 20 23 43
49 20 ▶ return $word
Branch: 1 branch
BranchTrueFalseTotal
if $word =~ s/ (?: \x{622}\x{628}\x{627}\x{62f} | \x{628}\x{627}\x{631}\x{647} | \x{628}\x{646}\x{62f}\x{6cc} | \x{628}\x{646}\x{62f}\x{64a} | \x{62a}\x{631}\x{6cc}\x{646} | \x{62a}\x{631}\x{64a}\x{646} | \x{631}\x{6cc}\x{632}\x{6cc} | \x{631}\x{64a}\x{632}\x{64a} | \x{633}\x{627}\x{632}\x{6cc} | \x{633}\x{627}\x{632}\x{64a} | \x{6af}\x{6cc}\x{631}\x{6cc} | \x{6af}\x{64a}\x{631}\x{64a} | \x{647}\x{627}\x{6cc}\x{6cc} | \x{647}\x{627}\x{64a}\x{64a} ) $//x 13 7 20
50 if $word =~ s{ (?:
51 آباد | باره | بندی | بندي | ترین | ترين | ریزی |
52 ريزي | سازی | سازي | گیری | گيري | هایی | هايي
53 ) $}{}x;
54 }
55  
56 30 ▶ if ($length > 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > 6) 14 16 30
57 14 ▶ return $word
Branch: 1 branch
BranchTrueFalseTotal
if $word =~ s/ (?: \x{627}\x{646}\x{62f} | \x{627}\x{6cc}\x{645} | \x{627}\x{64a}\x{645} | \x{634}\x{627}\x{646} | \x{647}\x{627}\x{6cc} | \x{647}\x{627}\x{64a} ) $//x 6 8 14
58 if $word =~ s{ (?:
59 اند | ایم | ايم | شان | های | هاي
60 ) $}{}x;
61 }
62  
63 24 ▶ if ($length > 5) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > 5) 18 6 24
64 18 ▶ return normalize($word)
Branch: 1 branch
BranchTrueFalseTotal
if $word =~ s/ \x{627}\x{646} $//x 8 10 18
65 if $word =~ s{ ان $}{}x;
66  
67 10 ▶ return $word
Branch: 1 branch
BranchTrueFalseTotal
if $word =~ s/ (?: \x{627}\x{62a} | \x{627}\x{634} | \x{627}\x{645} | \x{62a}\x{631} | \x{631}\x{627} | \x{648}\x{646} | \x{647}\x{627} | \x{647}\x{621} | \x{6cc}\x{646} | \x{64a}\x{646} ) $//x 9 1 10
68 if $word =~ s{ (?:
69 ات | اش | ام | تر | را | ون | ها | هء | ین | ين
70 ) $}{}x;
71 }
72  
73 7 ▶ if ($length > 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > 3) 7 0 7
74 7 ▶ return $word
Branch: 1 branch
BranchTrueFalseTotal
if $word =~ s/ (?: \x{62a} | \x{634} | \x{645} | \x{647} | \x{6cc} | \x{64a} ) $//x 7 0 7
75 if $word =~ s{ (?: ت | ش | م | ه | ی | ي ) $}{}x;
76 }
77  
78 0 return $word;
79 }
80  
81 8 ▶sub normalize {
Subroutine normalize: called CC=4 SCAR=14.0
Pod undocumented
82 8 my ($word) = @_;
83  
84 8 ▶ return $word
Branch: 1 branch
BranchTrueFalseTotal
if length $word < 4 0 8 8
85 if length $word < 4;
86  
87 8 ▶ if ($word =~ s{ (?: ت | ر | ش | گ | م | ى ) $}{}x) {
Branch: 1 branch
BranchTrueFalseTotal
if ($word =~ s/ (?: \x{62a} | \x{631} | \x{634} | \x{6af} | \x{645} | \x{649} ) $//x) 8 0 8
88 8 ▶ return $word
Branch: 1 branch
BranchTrueFalseTotal
if length $word < 4 2 6 8
89 if length $word < 4;
90  
91 6 $word =~ s{ (?: ی | ي ) $}{}x;
92 }
93  
94 6 return $word;
95 }
96  
97 2 1;
98  
99 __END__
« UniNE/BG.pm ↑ Summary UniNE/DE.pm »