class SRS::Schedulers::SuperMemo2
Constants
- DEFAULT_EF
- FIRST_INTERVAL
- ITERATION_RESET_BOUNDARY
- MIN_EF
- REPEAT_BOUNDARY
- SECOND_INTERVAL
Public Class Methods
new()
click to toggle source
# File lib/srs/schedulers/SuperMemo2.rb, line 15 def initialize() end
Public Instance Methods
adjust_efactor(ef, score)
click to toggle source
# File lib/srs/schedulers/SuperMemo2.rb, line 59 def adjust_efactor(ef, score) q = score * 5 adjusted_efactor = ef + (0.1-(5.0 - q) * (0.08 + (5.0 - q) * 0.02)) adjusted_efactor < MIN_EF ? MIN_EF : adjusted_efactor end
adjust_interval(interval, ef)
click to toggle source
# File lib/srs/schedulers/SuperMemo2.rb, line 66 def adjust_interval(interval, ef) (interval * ef).round end
first_rep(score)
click to toggle source
# File lib/srs/schedulers/SuperMemo2.rb, line 18 def first_rep(score) fields = { "Due" => (Date.today + FIRST_INTERVAL).to_time, "Repeat" => score < REPEAT_BOUNDARY ? true : false, "E-Factor" => adjust_efactor(DEFAULT_EF, score), "Interval" => FIRST_INTERVAL, "Iteration" => 1 } return fields end
rep(score, fields)
click to toggle source
# File lib/srs/schedulers/SuperMemo2.rb, line 30 def rep(score, fields) ef = fields["E-Factor"].to_f interval = fields["Interval"].to_i iteration = fields["Iteration"].to_i repeat = (fields["Repeat"] == "true") if not repeat then iteration = 0 if score < ITERATION_RESET_BOUNDARY case iteration when 0 interval = FIRST_INTERVAL when 1 interval = SECOND_INTERVAL else interval = adjust_interval(interval, ef) end ef = adjust_efactor(ef, score) end fields["Due"] = (Date.today + interval).to_time fields["Repeat"] = score < REPEAT_BOUNDARY ? true : false fields["E-Factor"] = ef fields["Interval"] = interval fields["Iteration"] = iteration + 1 return fields end