line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Sandy::Role::Counter; |
2
|
|
|
|
|
|
|
# ABSTRACT: Bayes counter |
3
|
|
|
|
|
|
|
|
4
|
6
|
|
|
6
|
|
4423
|
use App::Sandy::Base 'role'; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
41
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.24'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub with_make_counter { |
9
|
|
|
|
|
|
|
# ALgorithm based in perlfaq: |
10
|
|
|
|
|
|
|
# How do I select a random line from a file? |
11
|
|
|
|
|
|
|
# "The Art of Computer Programming" |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
0
|
0
|
|
my ($self, $num, $picks, $rng) = @_; |
14
|
|
|
|
|
|
|
return sub { |
15
|
0
|
|
|
0
|
|
|
state $count_down = $num; |
16
|
0
|
|
|
|
|
|
state $picks_left = $picks; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my $rc = 0; |
19
|
0
|
|
|
|
|
|
my $rand = $rng->get_n($count_down); |
20
|
|
|
|
|
|
|
|
21
|
0
|
0
|
|
|
|
|
if ($rand < $picks_left) { |
22
|
0
|
|
|
|
|
|
$rc = 1; |
23
|
0
|
|
|
|
|
|
$picks_left--; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
$count_down--; |
27
|
0
|
|
|
|
|
|
return $rc; |
28
|
0
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
__END__ |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=pod |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=encoding UTF-8 |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 NAME |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
App::Sandy::Role::Counter - Bayes counter |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 VERSION |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
version 0.24 |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 AUTHORS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=over 4 |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item * |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Thiago L. A. Miller <tmiller@mochsl.org.br> |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item * |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
J. Leonel Buzzo <lbuzzo@mochsl.org.br> |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item * |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Felipe R. C. dos Santos <fsantos@mochsl.org.br> |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=item * |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Helena B. Conceição <hconceicao@mochsl.org.br> |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item * |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Rodrigo Barreiro <rbarreiro@mochsl.org.br> |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item * |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Gabriela Guardia <gguardia@mochsl.org.br> |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item * |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Fernanda Orpinelli <forpinelli@mochsl.org.br> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item * |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Rafael Mercuri <rmercuri@mochsl.org.br> |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item * |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Rodrigo Barreiro <rbarreiro@mochsl.org.br> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item * |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Pedro A. F. Galante <pgalante@mochsl.org.br> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=back |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This software is Copyright (c) 2023 by Teaching and Research Institute from Sírio-Libanês Hospital. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This is free software, licensed under: |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |