BV/Cosine.pm

filter: Statementstmt 100% 16 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 100% 22 / 22 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« BV.pm ↑ Summary BV/Dice.pm »
1 package Set::Similarity::BV::Cosine;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use parent 'Set::Similarity::BV';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $VERSION = '0.06';
9  
10 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 9 ▶sub from_integers {
Subroutine from_integers: called CC=1 SCAR=0.0
Pod documented
13 9 my ($self, $v1, $v2) = @_;
14  
15 #print Dumper($v1, $v2);
16 #print 'from_integers() $v1: ',$v1->[0],' $v2: ',$v2->[0],"\n";
17  
18 #print 'from_integers: ',"\n";
19 #print ' $self->bits($v1): ',$self->bits($v1),' ',"\n";
20 #print ' $self->bits($v2): ',$self->bits($v2),' ',"\n";
21 #print ' $self->intersection($v1,$v2): ',$self->intersection($v1,$v2),' ',"\n";
22 #print ' $self->bits($v2): ',$self->bits($v2),' ',"\n";
23  
24 # it is so simple because the vectors contain only 0 and 1
25 return (
26 9 $self->intersection($v1,$v2) / (
27 sqrt($self->bits($v1)) * sqrt($self->bits($v2))
28 )
29 );
30 }
31  
32 1 1;
33  
34 __END__
« BV.pm ↑ Summary BV/Dice.pm »