blib/lib/EBook/Ishmael/CharDet/CP.pm

filter: Statementstmt 82.0% 32 / 39 Branchbran 80.0% 8 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 58.3% 7 / 12 Podpod 0.0% 0 / 8 totaltotal 68.1% 47 / 69 CC 7 SCAR 10.4
CC
7
Cov
82%
take
5.0
confidence
3.6
ignore
2.0
CRAP 2.8
« blib/lib/EBook/Ishmael/EBook/Metadata.pm ↑ Summary blib/lib/EBook/Ishmael/EBook/XHTML.pm »
1 package EBook::Ishmael::CharDet::CP;
2 18 ▶use 5.016;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 18 our $VERSION = '2.03';
4 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 18 ▶use EBook::Ishmael::CharDet::Constants qw(:CONSTANTS);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 sub new {
10  
11 536 ▶ my ($class) = @_;
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
12  
13 536 my $self = {
14 Freqs => 0,
15 Bigrams => 0,
16 Prev => undef,
17 Total => 0,
18 };
19 536 return bless $self, $class;
20  
21 }
22  
23 sub take {
24  
25 274432 ▶ my ($self, $data) = @_;
Subroutine take: called CC=5 SCAR=16.1
Pod undocumented
26  
27 274432 for my $i (0 .. length($data) - 1) {
28 4390912 my $c = substr $data, $i, 1;
29 4390912 ▶ if ($self->ignore($c)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->ignore($c)) { } 614927 3775985 4390912
elsif (defined $self->{'Prev'}) { } 3237754 538231 3775985
30 614927 undef $self->{Prev};
31 } elsif (defined $self->{Prev}) {
32 3237754 ▶ if ($self->freq_bigram($self->{Prev} . $c)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->freq_bigram($self->{"Prev"} . $c)) 748367 2489387 3237754
33 748367 $self->{Freqs}++;
34 }
35 3237754 $self->{Bigrams}++;
36 3237754 $self->{Prev} = $c;
37 } else {
38 538231 $self->{Prev} = $c;
39 }
40 4390912 $self->{Total}++;
41 }
42  
43 274432 return TAKE_OK;
44  
45 }
46  
47 0 ▶sub ignore { die "ignore() not implemented" }
Subroutine ignore: not called CC=1 SCAR=6.9
Pod undocumented
48  
49 0 ▶sub freq_bigram { die "freq_bigram() not implemented" }
Subroutine freq_bigram: not called CC=1 SCAR=6.9
Pod undocumented
50  
51 0 ▶sub dist_ratio { die "dist_ratio() not implemented" }
Subroutine dist_ratio: not called CC=1 SCAR=6.9
Pod undocumented
52  
53 sub confidence {
54  
55 536 ▶ my ($self) = @_;
Subroutine confidence: called CC=3 SCAR=12.7
Pod undocumented
56  
57 536 ▶ if ($self->{Total} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"Total"} == 0) 0 536 536
58 0 return 0;
59 }
60  
61 536 ▶ if ($self->{Freqs} == $self->{Bigrams}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"Freqs"} == $self->{"Bigrams"}) 0 536 536
62 0 return 0.99;
63 }
64  
65 536 return $self->{Freqs} / $self->{Bigrams};
66  
67 }
68  
69 0 ▶sub bad { 0 }
Subroutine bad: not called CC=1 SCAR=6.9
Pod undocumented
70  
71 0 ▶sub encoding { die "encoding() not implemented" }
Subroutine encoding: not called CC=1 SCAR=6.9
Pod undocumented
72  
73 18 1;
74  
« blib/lib/EBook/Ishmael/EBook/Metadata.pm ↑ Summary blib/lib/EBook/Ishmael/EBook/XHTML.pm »