| blib/lib/Set/Similarity/BV/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::BV::Cosine; | ||||||
| 2 | |||||||
| 3 | 1 | 1 | 617 | use strict; | |||
| 1 | 2 | ||||||
| 1 | 28 | ||||||
| 4 | 1 | 1 | 3 | use warnings; | |||
| 1 | 2 | ||||||
| 1 | 27 | ||||||
| 5 | |||||||
| 6 | 1 | 1 | 437 | use parent 'Set::Similarity::BV'; | |||
| 1 | 276 | ||||||
| 1 | 6 | ||||||
| 7 | |||||||
| 8 | our $VERSION = '0.04'; | ||||||
| 9 | |||||||
| 10 | sub from_integers { | ||||||
| 11 | 6 | 6 | 1 | 6 | my ($self, $v1, $v2) = @_; | ||
| 12 | |||||||
| 13 | # it is so simple because the vectors contain only 0 and 1 | ||||||
| 14 | return ( | ||||||
| 15 | 6 | 16 | $self->intersection($v1,$v2) / ( | ||||
| 16 | sqrt($self->bits($v1)) * sqrt($self->bits($v1)) | ||||||
| 17 | ) | ||||||
| 18 | ); | ||||||
| 19 | } | ||||||
| 20 | |||||||
| 21 | 1; | ||||||
| 22 | |||||||
| 23 | __END__ |