| blib/lib/Set/Similarity/Cosine.pm | |||
|---|---|---|---|
| Criterion | Covered | Total | % | 
| statement | 11 | 11 | 100.0 | 
| branch | n/a | ||
| condition | n/a | ||
| subroutine | 4 | 4 | 100.0 | 
| pod | 1 | 1 | 100.0 | 
| total | 16 | 16 | 100.0 | 
| line | stmt | bran | cond | sub | pod | time | code | 
|---|---|---|---|---|---|---|---|
| 1 | package Set::Similarity::Cosine; | ||||||
| 2 | |||||||
| 3 | 1 | 1 | 648 | use strict; | |||
| 1 | 1 | ||||||
| 1 | 33 | ||||||
| 4 | 1 | 1 | 4 | use warnings; | |||
| 1 | 1 | ||||||
| 1 | 31 | ||||||
| 5 | |||||||
| 6 | 1 | 1 | 499 | use parent 'Set::Similarity'; | |||
| 1 | 274 | ||||||
| 1 | 6 | ||||||
| 7 | |||||||
| 8 | our $VERSION = '0.026'; | ||||||
| 9 | |||||||
| 10 | sub from_sets { | ||||||
| 11 | 21 | 21 | 1 | 22 | my ($self, $set1, $set2) = @_; | ||
| 12 | |||||||
| 13 | # it is so simple because the vectors contain only 0 and 1 | ||||||
| 14 | return ( | ||||||
| 15 | 21 | 41 | $self->intersection($set1,$set2) / (sqrt(scalar @$set1) * sqrt(scalar @$set2)) | ||||
| 16 | ); | ||||||
| 17 | } | ||||||
| 18 | |||||||
| 19 | 1; | ||||||
| 20 | |||||||
| 21 | __END__ |