blib/lib/Lingua/Stem/Patch.pm

filter: Statementstmt 95.0% 38 / 40 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.3% 12 / 13 Podpod 100% 2 / 2 totaltotal 93.6% 59 / 63 CC 5 SCAR 4.3
CC
5
Cov
94%
_build_stemmer
2.0
__ANON__
2.0
__ANON__
2.0
CRAP 1.5
« blib/lib/Lingua/Stem/Patch/IO.pm ↑ Summary
1 package Lingua::Stem::Patch;
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 Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 our $VERSION = '0.05';
11  
12 2 my @languages = qw( eo io pl );
13 2 my %is_language = map { $_ => 1 } @languages;
14  
15 has language => (
16 is => 'rw',
17 isa => sub { croak "Invalid language '$_[0]'"
18 7 ▶ unless $is_language{$_[0]} },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless $is_language{$_[0]} 4 3 7
19 7 ▶ coerce => sub { defined $_[0] ? lc $_[0] : '' },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 6 1 7
20 3 ▶ trigger => sub { $_[0]->_clear_stemmer },
Subroutine __ANON__: called CC=1 SCAR=0.0
21 2 required => 1,
22 );
23  
24 has aggressive => (
25 is => 'rw',
26 2 ▶ coerce => sub { !!$_[0] },
Subroutine __ANON__: called CC=1 SCAR=0.0
27 0 ▶ trigger => sub { $_[0]->_clear_stemmer },
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 2 default => 0,
29 );
30  
31 2 has _stemmer => (
32 is => 'rw',
33 builder => '_build_stemmer',
34 clearer => '_clear_stemmer',
35 lazy => 1,
36 );
37  
38 sub _build_stemmer {
39 3 ▶ my $self = shift;
Subroutine _build_stemmer: called CC=2 SCAR=7.1
40 3 my $language = uc $self->language;
41 3 my $function = 'stem';
42  
43 3 ▶ if ($self->aggressive) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->aggressive) 0 3 3
44 0 $function .= '_aggressive';
45 }
46  
47 3 require "Lingua/Stem/Patch/$language.pm";
48 3 $self->_stemmer( \&{"Lingua::Stem::Patch::${language}::${function}"} );
49 }
50  
51 sub languages {
52 6 ▶ return @languages;
Subroutine languages: called CC=1 SCAR=0.0
Pod documented
53 }
54  
55 sub stem {
56 9 ▶ my $self = shift;
Subroutine stem: called CC=2 SCAR=6.9
Pod documented
57 9 my @stems = map { $self->_stemmer->($_) } @_;
58  
59 9 ▶ return wantarray ? @stems : pop @stems;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 3 6 9
60 }
61  
62 2 1;
63  
64 __END__
« blib/lib/Lingua/Stem/Patch/IO.pm ↑ Summary