Categorizer/Learner/Guesser.pm

filter: Statementstmt 72.7% 16 / 22 Branchbran 25.0% 1 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod 0.0% 0 / 2 totaltotal 63.6% 21 / 33 CC 4 SCAR 11.0
CC
4
Cov
65%
get_scores
6.0
create_model
3.0
BEGIN
1.0
CRAP 3.0
« Categorizer/FeatureVector.pm ↑ Summary Categorizer/Storable.pm »
1 package AI::Categorizer::Learner::Guesser;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use AI::Categorizer::Learner;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use base qw(AI::Categorizer::Learner);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶sub create_model {
Subroutine create_model: called CC=3 SCAR=11.0
Pod undocumented
8 1 my $self = shift;
9 1 my $k = $self->knowledge_set;
10 1 my $num_docs = $k->documents;
11
12 1 foreach my $cat ($k->categories) {
13 2 ▶ next unless $cat->documents;
Branch: 1 branch
BranchTrueFalseTotal
unless $cat->documents 0 2 2
14 2 $self->{model}{$cat->name} = $cat->documents / $num_docs;
15 }
16 }
17  
18 0 ▶sub get_scores {
Subroutine get_scores: not called CC=2 SCAR=17.9
Pod undocumented
19 0 my ($self, $newdoc) = @_;
20
21 0 my %scores;
22 0 ▶ while (my ($cat, $prob) = each %{$self->{model}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$self{"model"};}) 0 0 0
23 0 $scores{$cat} = 0.5 + $prob - rand();
24 }
25
26 0 return (\%scores, 0.5);
27 }
28  
29 1 1;
30  
31 __END__
« Categorizer/FeatureVector.pm ↑ Summary Categorizer/Storable.pm »