File Coverage

blib/lib/Set/Similarity/Jaccard.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 18 18 100.0


line stmt bran cond sub pod time code
1             package Set::Similarity::Jaccard;
2              
3 1     1   655 use strict;
  1         2  
  1         32  
4 1     1   3 use warnings;
  1         2  
  1         34  
5              
6 1     1   554 use parent 'Set::Similarity';
  1         311  
  1         8  
7              
8             our $VERSION = '0.026';
9              
10             sub from_sets {
11 30     30 1 29 my ($self, $set1, $set2) = @_;
12              
13 30         53 my $intersection = $self->intersection($set1,$set2);
14 30         61 my $union = $self->combined_length($set1,$set2) - $intersection;
15             # ( A intersect B ) / (A union B)
16 30         126 return ($intersection / $union);
17             }
18              
19             1;
20              
21             __END__