diff options
Diffstat (limited to 'gnosis-algorithm.el')
-rw-r--r-- | gnosis-algorithm.el | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/gnosis-algorithm.el b/gnosis-algorithm.el index c10d9c9..9117ad9 100644 --- a/gnosis-algorithm.el +++ b/gnosis-algorithm.el @@ -84,16 +84,12 @@ The structure of the given date is (YEAR MONTH DAY)." (- (time-to-days (current-time)) (time-to-days given-date)))) -(defun gnosis-algorithm-e-factor (ef quality) - "Calculate new e-factor given existing EF and binary QUALITY, 0 or 1." - (cond - ((not (numberp quality)) - (error "Invalid argument passed to gnosis-algorithm-e-factor")) - ((= quality 0) ;; If the quality score is 0 (fail), decrease the ef by a small penalty - (max 1.3 (- ef (cadr gnosis-algorithm-ef)))) - ((= quality 1) ;; If the quality score is 1 (pass), increase the ef by a small reward - (+ ef (car gnosis-algorithm-ef))) - (t (error "Invalid quality score passed to gnosis-algorithm-e-factor")))) + +(defun gnosis-algorithm-e-factor (ef success) + "Calculate the new e-factor given existing EF and SUCCESS, either t or nil." + (pcase success + (`t (+ ef (car gnosis-algorithm-ef))) + (`nil (max 1.3 (- ef (cadr gnosis-algorithm-ef)))))) (cl-defun gnosis-algorithm-next-interval (&key last-interval review-num ef success failure-factor successful-reviews successful-reviews-c fails-c fails-t initial-interval) @@ -114,8 +110,6 @@ Returns a list of: (INTERVAL N EF) where, - Next review date in (yyyy mm dd) format. - REVIEW-NUM: Incremented by 1. - EF : Modified based on the recall success for the item." - (cl-assert (and (>= success 0) - (<= success 1))) ;; Check if gnosis-algorithm-ff is lower than 1 & is total-ef above 1.3 (cond ((>= gnosis-algorithm-ff 1) (error "Value of `gnosis-algorithm-ff' must be lower than 1")) @@ -128,23 +122,21 @@ Returns a list of: (INTERVAL N EF) where, ;; thus ignore initial intervals (interval (cond + ;; TODO: Rewrite this! ;; First successful review -> first interval - ((and (= successful-reviews 0) - (= success 1)) - (car initial-interval)) + ((and (= successful-reviews 0) success + (car initial-interval))) ;; Second successful review -> second interval - ((and (= successful-reviews 1) - (= success 1) - (= fails-c 0)) + ((and (= successful-reviews 1) success) (cadr initial-interval)) ;; When successful-reviews-c is above 3, use 150% or 180% ;; of ef depending on the value of successful-reviews - ((and (= success 1) + ((and success (>= successful-reviews-c 3) (>= review-num 5) (> last-interval 1)) (* (* ef (if (>= successful-reviews 10) 1.8 1.5)) last-interval)) - ((and (= success 0) + ((and (equal success nil) (> fails-c 3) (>= review-num 5) (> last-interval 1)) @@ -152,10 +144,10 @@ Returns a list of: (INTERVAL N EF) where, ;; failure-factor depending on the value of total failed ;; reviews. (* (max (min 0.8 (* failure-factor (if (>= fails-t 10) 1.8 1.5))) - failure-factor) - last-interval)) + failure-factor) + last-interval)) ;; For everything else - (t (if (= success 1) + (t (if success (* ef last-interval) (* failure-factor last-interval)))))) (list (gnosis-algorithm-date (round interval)) next-ef))) |