| 1 | package HTML::ListScraper::Occurence; | ||||||||||
| 2 | |||||||||||
| 3 | 10 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 10 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 84193 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 7 | 84193 | my ($class, $length, $pos) = @_; | |||||||||
| 8 | 84193 | my $self = { length => $length, spread => 1, | |||||||||
| 9 | edge => $pos, positions => [ $pos ] }; | ||||||||||
| 10 | 84193 | bless $self, $class; | |||||||||
| 11 | |||||||||||
| 12 | 84193 | return $self; | |||||||||
| 13 | } | ||||||||||
| 14 | |||||||||||
| 15 | 102664 | ▶ | sub spread { | ||||||||
|
Subroutine
spread: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 16 | 102664 | my $self = shift; | |||||||||
| 17 | |||||||||||
| 18 | 102664 | return $self->{spread}; | |||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | 2869 | ▶ | sub len { | ||||||||
|
Subroutine
len: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 22 | 2869 | my $self = shift; | |||||||||
| 23 | |||||||||||
| 24 | 2869 | return $self->{length}; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 2854 | ▶ | sub first_pos { | ||||||||
|
Subroutine
first_pos: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 28 | 2854 | my $self = shift; | |||||||||
| 29 | |||||||||||
| 30 | 2854 | return $self->{positions}->[0]; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 3915 | ▶ | sub log_score { | ||||||||
|
Subroutine
log_score: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 34 | 3915 | my $self = shift; | |||||||||
| 35 | |||||||||||
| 36 | # return log($self->{spread}) * $self->{length}; | ||||||||||
| 37 | 3915 | return log($self->{spread}) * log($self->{length}); | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 80120 | ▶ | sub positions { | ||||||||
|
Subroutine
positions: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 41 | 80120 | my $self = shift; | |||||||||
| 42 | |||||||||||
| 43 | 80120 | return @{$self->{positions}}; | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 318147 | ▶ | sub append_pos { | ||||||||
|
Subroutine
append_pos: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||
| 47 | 318147 | my ($self, $pos) = @_; | |||||||||
| 48 | |||||||||||
| 49 | 318147 | my $count = scalar(@{$self->{positions}}); | |||||||||
| 50 | 318147 | ▶ | if ($pos <= $self->{positions}->[$count - 1]) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | 0 | die "position $pos out of order"; | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 318147 | push @{$self->{positions}}, $pos; | |||||||||
| 55 | |||||||||||
| 56 | 318147 | ▶ | if ($self->{edge} + $self->{length} <= $pos) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | 190840 | ++($self->{spread}); | |||||||||
| 58 | 190840 | $self->{edge} = $pos; | |||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | 318147 | return $self->{spread}; | |||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | 10 | 1; | |||||||||