blib/lib/Lingua/Stem/Patch/IO.pm

filter: Statementstmt 100% 36 / 36 Branchbran 100% 12 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 2 totaltotal 96.4% 55 / 57 SCAR 22.0
CC
9
Cov
100%
stem
6.0
stem_aggressive
4.0
BEGIN
1.0
CRAP 9.0
« blib/lib/Lingua/Stem/Patch/EO.pm ↑ Summary Build »
1 package Lingua::Stem::Patch::IO;
2  
3 4 ▶use v5.8.1;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 our $VERSION = '0.04';
10 4 our @EXPORT_OK = qw( stem stem_io stem_aggressive stem_io_aggressive );
11  
12 4 *stem_io = \&stem;
13 4 *stem_io_aggressive = \&stem_aggressive;
14  
15 my %protect = (
16 4 root => { map { $_ => 1 } qw(
17 la li me ni on vi
18 ) },
19 );
20  
21 sub stem {
22 117 ▶ my $word = lc shift;
Subroutine stem: called CC=6 SCAR=17.9
Pod undocumented
23  
24 117 for ($word) {
25 # standalone roots
26 117 ▶ last if $protect{root}{$word};
Branch: 1 branch
BranchTrueFalseTotal
if $protect{"root"}{$word} 14 103 117
27  
28 # nouns: -on -i -in → -o
29 103 ▶ last if s{ (?: on | in? ) $}{o}x;
Branch: 1 branch
BranchTrueFalseTotal
if s/ (?: on | in? ) $/o/x 6 97 103
30  
31 # remove -u from pronouns: elu ilu olu onu
32 97 ▶ last if s{ (?<= ^ [eio] l | on ) u $}{}x;
Branch: 1 branch
BranchTrueFalseTotal
if s/ (?<= ^ [eio] l | on ) u $//x 8 89 97
33  
34 # pariciple adjectives: -inta -anta -onta -ita -ata -ota → -ar
35 89 ▶ last if s{ (?: [aio] n? t ) a $}{ar}x;
Branch: 1 branch
BranchTrueFalseTotal
if s/ (?: [aio] n? t ) a $/ar/x 12 77 89
36  
37 # verbs: -ir -or -is -as -os -us -ez → -ar
38 77 s{ (?: [io] r | [aiou] s | ez ) $}{ar}x;
39  
40 # remove -ab- from verbs
41 77 s{ ab (?= ar $ ) }{}x;
42 }
43  
44 117 return $word;
45 }
46  
47 sub stem_aggressive {
48 58 ▶ my $word = stem(shift);
Subroutine stem_aggressive: called CC=4 SCAR=13.9
Pod undocumented
49  
50 58 for ($word) {
51 # standalone roots
52 58 ▶ last if $protect{root}{$word};
Branch: 1 branch
BranchTrueFalseTotal
if $protect{"root"}{$word} 8 50 58
53  
54 # remove final suffix
55 50 s{ (?: [aeo] | ar ) $}{}x;
56  
57 # remove -u from pronouns: elu ilu olu onu
58 50 ▶ last if s{ (?<= ^ [eio] l | on ) u $}{}x;
Branch: 1 branch
BranchTrueFalseTotal
if s/ (?<= ^ [eio] l | on ) u $//x 4 46 50
59 }
60  
61 58 return $word;
62 }
63  
64 4 1;
65  
66 __END__
« blib/lib/Lingua/Stem/Patch/EO.pm ↑ Summary Build »