UniNE/BG.pm

filter: Statementstmt 100% 61 / 61 Branchbran 94.4% 34 / 36 Conditioncond 94.4% 17 / 18 MC/DCmcdc 88.8% 8 / 9 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 3 totaltotal 94.8% 130 / 137 CC 25 SCAR 20.9
CC
25
Cov
97%
remove_plural
13.0
stem
7.0
remove_article
7.0
CRAP 8.1
« UniNE/CS.pm ↑ Summary UniNE/FA.pm »
1 package Lingua::Stem::UniNE::BG;
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 our $VERSION = '0.08';
12 2 our @EXPORT_OK = qw( stem stem_bg );
13  
14 2 *stem_bg = \&stem;
15  
16 24 ▶sub stem {
Subroutine stem: called CC=7 SCAR=19.5
Pod undocumented
17 24 my ($word) = @_;
18  
19 24 $word = NFC fc $word;
20  
21 24 my $length = length $word;
22  
23 24 ▶ return $word
Branch: 1 branch
BranchTrueFalseTotal
if $length < 4 0 24 24
24 if $length < 4;
25  
26 24 ▶ if ($length > 5) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > 5) 19 5 24
27 19 ▶ return $word
Branch: 1 branch
BranchTrueFalseTotal
if $word =~ s/ \x{438}\x{449}\x{430} $//x 0 19 19
28 if $word =~ s{ ища $}{}x;
29 }
30  
31 24 $word = remove_article($word);
32 24 $word = remove_plural($word);
33 24 $length = length $word;
34  
35 24 ▶ if ($length > 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > 3) 23 1 24
36 23 $word =~ s{ я $}{}x; # masculine
37  
38 # normalization (e.g., -а could be a definite article or plural form)
39 23 $word =~ s{ [аео] $}{}x;
40  
41 23 $length = length $word;
42 }
43  
44 24 ▶ if ($length > 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > 4) 11 13 24
45 11 $word =~ s{ е (?= н $) }{}x; # -ен → -н
46  
47 11 $length = length $word;
48 }
49  
50 24 ▶ if ($length > 5) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > 5) 6 18 24
51 6 $word =~ s{ ъ (?= \p{Cyrl} $) }{}x; # -ъ� → -�
52 }
53  
54 24 return $word;
55 }
56  
57 24 ▶sub remove_article {
Subroutine remove_article: called CC=7 SCAR=19.5
Pod undocumented
58 24 my ($word) = @_;
59 24 my $length = length $word;
60  
61 24 ▶ if ($length > 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > 6) 13 11 24
62 # definite article with adjectives and masculine
63 13 ▶ return $word
Branch: 1 branch
BranchTrueFalseTotal
if $word =~ s/ \x{438}\x{44f}\x{442} $//x 1 12 13
64 if $word =~ s{ ият $}{}x;
65 }
66  
67 23 ▶ if ($length > 5) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > 5) 18 5 23
68 18 ▶ return $word
Branch: 1 branch
BranchTrueFalseTotal
if $word =~ s/ (?: \x{438}\x{44f} # definite articles for nouns: | \x{44a}\x{442} # \x{2219} masculine | \x{442}\x{430} # \x{2219} feminine | \x{442}\x{43e} # \x{2219} neutral | \x{442}\x{435} # \x{2219} plural ) $//x 9 9 18
69 if $word =~ s{ (?:
70 ия # definite articles for nouns:
71 | ът # ∙ masculine
72 | та # ∙ feminine
73 | то # ∙ neutral
74 | те # ∙ plural
75 ) $}{}x;
76 }
77  
78 14 ▶ if ($length > 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > 4) 12 2 14
79 12 ▶ return $word
Branch: 1 branch
BranchTrueFalseTotal
if $word =~ s/ \x{44f}\x{442} $//x 1 11 12
80 if $word =~ s{ ят $}{}x; # article for masculine
81 }
82  
83 13 return $word;
84 }
85  
86 24 ▶sub remove_plural {
Subroutine remove_plural: called CC=13 SCAR=25.7
Pod undocumented
87 24 my ($word) = @_;
88 24 my $length = length $word;
89  
90 # specific plural rules for some words (masculine)
91 24 ▶ if ($length > 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > 6) 8 16 24
92 8 ▶ return $word
Branch: 1 branch
BranchTrueFalseTotal
if $word =~ s/ \x{43e}\x{432}\x{435} $//x or $word =~ s/ \x{435}\x{432}\x{435} $/\x{439}/x or $word =~ s/ \x{43e}\x{432}\x{446}\x{438} $/\x{43e}/x 2 6 8
Condition83%5/6
$word =~ s/ \x{43e}\x{432}\x{435} $//x or $word =~ s/ \x{435}\x{432}\x{435} $/\x{439}/x or $word =~ s/ \x{43e}\x{432}\x{446}\x{438} $/\x{43e}/x
l!l&&r!l&&!r
116
$word =~ s/ \x{43e}\x{432}\x{435} $//x or $word =~ s/ \x{435}\x{432}\x{435} $/\x{439}/x
l!l&&r!l&&!r
107
MC/DC66%2/3
$word =~ s/ \x{43e}\x{432}\x{435} $//x or $word =~ s/ \x{435}\x{432}\x{435} $/\x{439}/x or $word =~ s/ \x{43e}\x{432}\x{446}\x{438} $/\x{43e}/x
$word =~ s/ \x{43e}\x{432}\x{435} $//x $word =~ s/ \x{435}\x{432}\x{435} $/\x{439}/x $word =~ s/ \x{43e}\x{432}\x{446}\x{438} $/\x{43e}/x
Truth table75%3/4
A or B or C
A= $word =~ s/ \x{43e}\x{432}\x{435} $//xB= $word =~ s/ \x{435}\x{432}\x{435} $/\x{439}/xC= $word =~ s/ \x{43e}\x{432}\x{446}\x{438} $/\x{43e}/x
ABCresult
1XX1
01X1
0011
0000
93 if $word =~ s{ ове $}{}x
94 || $word =~ s{ еве $}{й}x
95 || $word =~ s{ овци $}{о}x;
96 }
97  
98 22 ▶ if ($length > 5) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > 5) 12 10 22
99 12 ▶ return $word
Branch: 1 branch
BranchTrueFalseTotal
if $word =~ s/ \x{437}\x{438} $/\x{433}/x or $word =~ s/ \x{435} ( \p{Cyrl} ) \x{438} $/\x{44f}$1/x or $word =~ s/ \x{446}\x{438} $/\x{43a}/x or $word =~ s/ (?: \x{442}\x{430} | \x{438}\x{449}\x{430} ) $//x 6 6 12
Condition100%9/9
$word =~ s/ \x{437}\x{438} $/\x{433}/x or $word =~ s/ \x{435} ( \p{Cyrl} ) \x{438} $/\x{44f}$1/x or $word =~ s/ \x{446}\x{438} $/\x{43a}/x or $word =~ s/ (?: \x{442}\x{430} | \x{438}\x{449}\x{430} ) $//x
l!l&&r!l&&!r
336
$word =~ s/ \x{437}\x{438} $/\x{433}/x or $word =~ s/ \x{435} ( \p{Cyrl} ) \x{438} $/\x{44f}$1/x or $word =~ s/ \x{446}\x{438} $/\x{43a}/x
l!l&&r!l&&!r
219
$word =~ s/ \x{437}\x{438} $/\x{433}/x or $word =~ s/ \x{435} ( \p{Cyrl} ) \x{438} $/\x{44f}$1/x
l!l&&r!l&&!r
1110
MC/DC100%4/4
$word =~ s/ \x{437}\x{438} $/\x{433}/x or $word =~ s/ \x{435} ( \p{Cyrl} ) \x{438} $/\x{44f}$1/x or $word =~ s/ \x{446}\x{438} $/\x{43a}/x or $word =~ s/ (?: \x{442}\x{430} | \x{438}\x{449}\x{430} ) $//x
$word =~ s/ \x{437}\x{438} $/\x{433}/x $word =~ s/ \x{435} ( \p{Cyrl} ) \x{438} $/\x{44f}$1/x $word =~ s/ \x{446}\x{438} $/\x{43a}/x $word =~ s/ (?: \x{442}\x{430} | \x{438}\x{449}\x{430} ) $//x
Truth table100%5/5
A or B or C or D
A= $word =~ s/ \x{437}\x{438} $/\x{433}/xB= $word =~ s/ \x{435} ( \p{Cyrl} ) \x{438} $/\x{44f}$1/xC= $word =~ s/ \x{446}\x{438} $/\x{43a}/xD= $word =~ s/ (?: \x{442}\x{430} | \x{438}\x{449}\x{430} ) $//x
ABCDresult
1XXX1
01XX1
001X1
00011
00000
100 if $word =~ s{ зи $}{г}x
101 || $word =~ s{ е ( \p{Cyrl} ) и $}{я$1}x # -е�и → -я�
102 || $word =~ s{ ци $}{к}x
103 || $word =~ s{ (?: та | ища ) $}{}x;
104 }
105  
106 16 ▶ if ($length > 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($length > 4) 11 5 16
107 11 ▶ return $word
Branch: 1 branch
BranchTrueFalseTotal
if $word =~ s/ \x{441}\x{438} $/\x{445}/x or $word =~ s/ \x{438} $//x 3 8 11
Condition100%3/3
$word =~ s/ \x{441}\x{438} $/\x{445}/x or $word =~ s/ \x{438} $//x
l!l&&r!l&&!r
128
MC/DC100%2/2
$word =~ s/ \x{441}\x{438} $/\x{445}/x or $word =~ s/ \x{438} $//x
$word =~ s/ \x{441}\x{438} $/\x{445}/x $word =~ s/ \x{438} $//x
Truth table100%3/3
A or B
A= $word =~ s/ \x{441}\x{438} $/\x{445}/xB= $word =~ s/ \x{438} $//x
ABresult
1X1
011
000
108 if $word =~ s{ си $}{х}x
109 || $word =~ s{ и $}{}x; # plural for various nouns and adjectives
110 }
111  
112 13 return $word;
113 }
114  
115 2 1;
116  
117 __END__
« UniNE/CS.pm ↑ Summary UniNE/FA.pm »