From 2d7752dfb299e069850a382d115fa65cf5660fbf Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 6 Feb 2024 12:14:55 +0200 Subject: gnosis-algorith: Adjust for second initial interval --- gnosis-algorithm.el | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'gnosis-algorithm.el') diff --git a/gnosis-algorithm.el b/gnosis-algorithm.el index c10d9c9..02b9a87 100644 --- a/gnosis-algorithm.el +++ b/gnosis-algorithm.el @@ -114,8 +114,8 @@ 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))) + (cl-assert (or (= 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")) @@ -134,8 +134,7 @@ Returns a list of: (INTERVAL N EF) where, (car initial-interval)) ;; Second successful review -> second interval ((and (= successful-reviews 1) - (= success 1) - (= fails-c 0)) + (= success 1)) (cadr initial-interval)) ;; When successful-reviews-c is above 3, use 150% or 180% ;; of ef depending on the value of successful-reviews -- cgit v1.2.3 From 49e797bbf0b14620408c3aa158551f7cac50adbe Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Thu, 8 Feb 2024 18:15:21 +0200 Subject: gnosis-algorithm-e-factor: Refactor to use t or nil --- gnosis-algorithm.el | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'gnosis-algorithm.el') diff --git a/gnosis-algorithm.el b/gnosis-algorithm.el index 02b9a87..11c99c8 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) -- cgit v1.2.3 From 1371fb75614e23dc791c452c07e2ca72206383e8 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Thu, 8 Feb 2024 18:20:20 +0200 Subject: gnosis-algorithm-next-interval: Refactor & update values for ef --- gnosis-algorithm.el | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'gnosis-algorithm.el') diff --git a/gnosis-algorithm.el b/gnosis-algorithm.el index 11c99c8..9117ad9 100644 --- a/gnosis-algorithm.el +++ b/gnosis-algorithm.el @@ -110,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 (or (= 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")) @@ -124,22 +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)) + ((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)) @@ -147,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))) -- cgit v1.2.3