line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Repetition::Interval; |
2
|
|
|
|
|
|
|
$Repetition::Interval::VERSION = '0.001'; |
3
|
2
|
|
|
2
|
|
139041
|
use Moo; |
|
2
|
|
|
|
|
22752
|
|
|
2
|
|
|
|
|
11
|
|
4
|
2
|
|
|
2
|
|
3888
|
use strictures 2; |
|
2
|
|
|
|
|
3247
|
|
|
2
|
|
|
|
|
78
|
|
5
|
2
|
|
|
2
|
|
1500
|
use Types::Standard qw(Num Int); |
|
2
|
|
|
|
|
153301
|
|
|
2
|
|
|
|
|
28
|
|
6
|
2
|
|
|
2
|
|
3103
|
use POSIX qw(round); |
|
2
|
|
|
|
|
12679
|
|
|
2
|
|
|
|
|
12
|
|
7
|
2
|
|
|
2
|
|
3889
|
use namespace::clean; |
|
2
|
|
|
|
|
23047
|
|
|
2
|
|
|
|
|
14
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: A library to calculate intervals for spaced repetition memorization |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has default_avg_grade => ( |
13
|
|
|
|
|
|
|
is => 'ro', |
14
|
|
|
|
|
|
|
isa => Num, |
15
|
|
|
|
|
|
|
default => sub { 2.5; } |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has priority => ( |
19
|
|
|
|
|
|
|
is => 'ro', |
20
|
|
|
|
|
|
|
isa => Int, |
21
|
|
|
|
|
|
|
default => sub { 4; } |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub calculate_new_mean { |
26
|
11
|
|
|
11
|
1
|
4960
|
my ($self, $current_grade, $review_cnt, $prev_mean) = @_; |
27
|
|
|
|
|
|
|
|
28
|
11
|
100
|
|
|
|
49
|
return ($self->default_avg_grade() + $current_grade) / 2 if $review_cnt == 1; |
29
|
|
|
|
|
|
|
|
30
|
9
|
|
|
|
|
33
|
return (($prev_mean*$review_cnt)/($review_cnt + 1)) + ($current_grade / ($review_cnt + 1)); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub schedule_next_review { |
35
|
12
|
|
|
12
|
1
|
48
|
my ($self, $current_grade, $review_cnt, $mean_of_grades) = @_; |
36
|
|
|
|
|
|
|
|
37
|
12
|
|
|
|
|
107
|
return round(1 + exp($current_grade - $self->priority())*$review_cnt**($mean_of_grades/2)); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub schedule_next_review_seconds { |
42
|
1
|
|
|
1
|
1
|
5
|
my $self = shift; |
43
|
1
|
|
|
|
|
4
|
return ($self->schedule_next_review(@_))*86_400; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |