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   671 use strict;
  1         2  
  1         32  
4 1     1   4 use warnings;
  1         1  
  1         32  
5              
6 1     1   445 use parent 'Set::Similarity';
  1         293  
  1         7  
7              
8             our $VERSION = '0.025';
9              
10             sub from_sets {
11 30     30 1 38 my ($self, $set1, $set2) = @_;
12              
13 30         54 my $intersection = $self->intersection($set1,$set2);
14 30         65 my $union = $self->combined_length($set1,$set2) - $intersection;
15             # ( A intersect B ) / (A union B)
16 30         128 return ($intersection / $union);
17             }
18              
19             1;
20              
21             __END__