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   750 use strict;
  1         2  
  1         29  
4 1     1   10 use warnings;
  1         2  
  1         26  
5              
6 1     1   456 use parent 'Set::Similarity';
  1         303  
  1         5  
7              
8             our $VERSION = '0.027';
9              
10             sub from_sets {
11 30     30 1 53 my ($self, $set1, $set2) = @_;
12              
13 30         69 my $intersection = $self->intersection($set1,$set2);
14 30         73 my $union = $self->combined_length($set1,$set2) - $intersection;
15             # ( A intersect B ) / (A union B)
16 30         200 return ($intersection / $union);
17             }
18              
19             1;
20              
21             __END__