File Coverage

blib/lib/AI/Categorizer/Experiment.pm
Criterion Covered Total %
statement 29 31 93.5
branch 3 6 50.0
condition n/a
subroutine 8 9 88.8
pod 3 3 100.0
total 43 49 87.7


line stmt bran cond sub pod time code
1             package AI::Categorizer::Experiment;
2              
3 6     6   5192 use strict;
  6         12  
  6         175  
4 6     6   27 use Class::Container;
  6         9  
  6         96  
5 6     6   27 use AI::Categorizer::Storable;
  6         13  
  6         126  
6 6     6   4426 use Statistics::Contingency;
  6         10434  
  6         172  
7              
8 6     6   64 use base qw(Class::Container AI::Categorizer::Storable Statistics::Contingency);
  6         10  
  6         790  
9              
10 6     6   28 use Params::Validate qw(:types);
  6         12  
  6         2182  
11             __PACKAGE__->valid_params
12             (
13             categories => { type => ARRAYREF|HASHREF },
14             sig_figs => { type => SCALAR, default => 4 },
15             );
16              
17             sub new {
18 8     8 1 2047 my $package = shift;
19 8         49 my $self = $package->Class::Container::new(@_);
20            
21 8         914 $self->{$_} = 0 foreach qw(a b c d);
22 8         26 my $c = delete $self->{categories};
23 8 50       89 $self->{categories} = { map {($_ => {a=>0, b=>0, c=>0, d=>0})}
  22         152  
24             UNIVERSAL::isa($c, 'HASH') ? keys(%$c) : @$c
25             };
26 8         48 return $self;
27             }
28              
29             sub add_hypothesis {
30 20     20 1 42 my ($self, $h, $correct, $name) = @_;
31 20 50       53 die "No hypothesis given to add_hypothesis()" unless $h;
32 20 50       82 $name = $h->document_name unless defined $name;
33            
34 20         65 $self->add_result([$h->categories], $correct, $name);
35             }
36              
37             sub stats_table {
38 0     0 1   my $self = shift;
39 0           $self->SUPER::stats_table($self->{sig_figs});
40             }
41              
42             1;
43              
44             __END__