emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* New module: org-learn, incremental reading
@ 2009-10-21  8:53 John Wiegley
  2009-10-21 12:23 ` Russell Adams
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: John Wiegley @ 2009-10-21  8:53 UTC (permalink / raw)
  To: Org-mode Mode; +Cc: Carsten Dominik

[-- Attachment #1: Type: text/plain, Size: 1977 bytes --]

The attached file, when loaded, provides two new commands:

   M-x org-smart-reschedule
   M-x org-agenda-smart-reschedule

The latter being only for the *Org Agenda* buffer.

You should use these commands on a scheduled entry, with state logging  
enabled for the DONE state.  It then reschedules the item to a future  
date based on the "SM-5" algorithm and a quality factor you are  
prompted for.

To summarize the SM-5 algorithm:

   1. After you read an item on the scheduled day, you hit M-x org- 
smart-reschedule.

   2. You are then asked how well you remember what you just read,  
from 0-5:

      5 - perfect response
      4 - correct response after a hesitation
      3 - correct response recalled with serious difficulty
      2 - incorrect response; where the correct one seemed easy to  
recall
      1 - incorrect response; the correct one remembered
      0 - complete blackout.

   3. If your answer is 4 or 5, the item will not be repeated.  If it  
is anything
      else, the item is rescheduled, to be read again on a future date.

   4. Based on the quality of your response, AND the number of times  
you've read
      the item so far, the amount of time being reschedulings will  
vary.  If your
      retention is good, the gaps grow wider; if it is poor, they grow  
shorter.

   5. Your "learning data" is kept in a special property  
called :LEARN_DATA:.  Do
      not modify this, as it controls how the algorithm reschedules  
after future
      repetitions, and based on past quality responses.

More about this algorithm can be read here: http://www.supermemo.com/english/ol/sm2.htm 
.

This contribution is made in honor of Russell Adams, who drove all the  
way to New Jersey from Kennedy airport to visit me today, and who  
brought up the idea of implementing it, based on an earlier proposal  
by Pere Quintana Seguí (http://article.gmane.org/gmane.emacs.orgmode/17781 
).

John


[-- Attachment #2: org-learn.el --]
[-- Type: application/octet-stream, Size: 7007 bytes --]

;;; org-learn.el --- Implements SuperMemo's incremental learning algorithm

;; Copyright (C) 2009
;;   Free Software Foundation, Inc.

;; Author: John Wiegley <johnw at gnu dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
;; Version: 6.31trans
;;
;; This file is part of GNU Emacs.
;;
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:

;; The file implements the learning algorithm described at
;; http://supermemo.com/english/ol/sm5.htm, which is a system for reading
;; material according to "spaced repetition".  See
;; http://en.wikipedia.org/wiki/Spaced_repetition for more details.
;;
;; To use, turn on state logging and schedule some piece of information you
;; want to read.  Then in the agenda buffer type

(require 'org)
(eval-when-compile
  (require 'cl)
  (require 'calendar))

(defgroup org-learn nil
  "Options concerning the learning code in Org-mode."
  :tag "Org Learn"
  :group 'org-progress)

(defcustom org-learning-fraction 0.5
  "Controls the rate at which EF is increased or decreased.
Must be a number between 0 and 1 (the greater it is the faster
the changes of the OF matrix)."
  :type 'float
  :group 'org-learn)

(defvar optimal-factors nil
  "A list of alists relating (N, EF) => OF.
The format is: ((N . ((EF . OF) ...)) ...)")

(defun initial-optimal-factor (n ef)
  (if (= 1 n)
      4
    ef))

(defun get-optimal-factor (n ef of-matrix)
  (let ((factors (assoc n of-matrix)))
    (or (and factors
	     (let ((ef-of (assoc ef (cdr factors))))
	       (and ef-of (cdr ef-of))))
	(initial-optimal-factor n ef))))

(defun set-optimal-factor (n ef of-matrix of)
  (let ((factors (assoc n of-matrix)))
    (if factors
	(let ((ef-of (assoc ef (cdr factors))))
	  (if ef-of
	      (setcdr ef-of of)
	    (push (cons ef of) (cdr factors))))
      (push (cons n (list (cons ef of))) of-matrix)))
  of-matrix)

(defun inter-repetition-interval (n ef &optional of-matrix)
  (let ((of (get-optimal-factor n ef of-matrix)))
    (if (= 1 n)
	of
      (* of (inter-repetition-interval (1- n) ef of-matrix)))))

(defun modify-e-factor (ef quality)
  (if (< ef 1.3)
      1.3
    (+ ef (- 0.1 (* (- 5 quality) (+ 0.08 (* (- 5 quality) 0.02)))))))

(defun modify-of (of q fraction)
  (let ((temp (* of (+ 0.72 (* q 0.07)))))
    (+ (* (- 1 fraction) of) (* fraction temp))))

(defun calculate-new-optimal-factor (interval-used quality used-of
						   old-of fraction)
  "This implements the SM-5 learning algorithm in Lisp.
INTERVAL-USED is the last interval used for the item in question.
QUALITY is the quality of the repetition response.
USED-OF is the optimal factor used in calculation of the last
interval used for the item in question.
OLD-OF is the previous value of the OF entry corresponding to the
relevant repetition number and the E-Factor of the item.
FRACTION is a number belonging to the range (0,1) determining the
rate of modifications (the greater it is the faster the changes
of the OF matrix).

Returns the newly calculated value of the considered entry of the
OF matrix."
  (let (;; the value proposed for the modifier in case of q=5
	(mod5 (/ (1+ interval-used) interval-used))
	;; the value proposed for the modifier in case of q=2
	(mod2 (/ (1- interval-used) interval-used))
	;; the number determining how many times the OF value will
	;; increase or decrease
	modifier)
    (if (< mod5 1.05)
	(setq mod5 1.05))
    (if (< mod2 0.75)
	(setq mod5 0.75))
    (if (> quality 4)
	(setq modifier (1+ (* (- mod5 1) (- quality 4))))
      (setq modifier (- 1 (* (/ (- 1 mod2) 2) (- 4 quality)))))
    (if (< modifier 0.05)
	(setq modifier 0.05))
    (setq new-of (* used-of modifier))
    (if (> quality 4)
	(if (< new-of old-of)
	    (setq new-of old-of)))
    (if (< quality 4)
	(if (> new-of old-of)
	    (setq new-of old-of)))
    (setq new-of (+ (* new-of fraction) (* old-of (- 1 fraction))))
    (if (< new-of 1.2)
	(setq new-of 1.2)
      new-of)))

(defvar initial-repetition-state '(-1 2.5 nil)
  "Here -1 = show now, 2.5 is the E-Factor, and nil is the OF-Matrix")

(defun determine-next-interval (n ef quality of-matrix)
  (assert (> n 0))
  (assert (and (>= quality 0) (<= quality 5)))
  (if (< quality 3)
      (list (inter-repetition-interval n ef) ef nil)
    (let ((next-ef (modify-e-factor ef quality)))
      (setq of-matrix
	    (set-optimal-factor n next-ef of-matrix
				(modify-of (get-optimal-factor n ef of-matrix)
					   quality learning-fraction))
	    ef next-ef)
      ;; For a zero-based quality of 4 or 5, don't repeat
      (if (>= quality 4)
	  (list 0 ef of-matrix)
	(list (inter-repetition-interval n ef of-matrix) ef of-matrix)))))

(defun org-smart-reschedule (quality)
  (interactive "nHow well did you remember the information (on a scale of 0-5)? ")
  (let* ((learn-str (org-entry-get (point) "LEARN_DATA"))
	 (learn-data (or (and learn-str
			      (read learn-str))
			 (copy-list initial-repetition-state)))
	 closed-dates)
    (save-excursion
      (goto-char (org-entry-beginning-position))
      (let ((end (org-entry-end-position)))
	(while (re-search-forward "- State \"DONE\".*\\[\\([^]]+\\)\\]" end t)
	  (push (org-time-string-to-time (match-string-no-properties 1))
		closed-dates))))
    (setq learn-data
	  (determine-next-interval (1+ (length closed-dates))
				   (nth 1 learn-data)
				   quality
				   (nth 2 learn-data)))
    (org-entry-put (point) "LEARN_DATA" (prin1-to-string learn-data))
    (if (= 0 (nth 0 learn-data))
	(org-schedule t)
      (org-schedule nil (time-add (current-time)
				  (days-to-time (nth 0 learn-data)))))))

(defun org-agenda-smart-reschedule (&optional arg)
  "Add a time-stamped note to the entry at point."
  (interactive "P")
  (org-agenda-check-no-diary)
  (let* ((marker (or (org-get-at-bol 'org-marker)
		     (org-agenda-error)))
	 (buffer (marker-buffer marker))
	 (pos (marker-position marker))
	 (hdmarker (org-get-at-bol 'org-hd-marker))
	 (inhibit-read-only t) ts)
    (with-current-buffer buffer
      (widen)
      (goto-char pos)
      (org-show-context 'agenda)
      (save-excursion
	(and (outline-next-heading)
	     (org-flag-heading nil)))   ; show the next heading
      (setq ts (call-interactively 'org-smart-reschedule)))
    (org-agenda-show-new-time marker ts "S")))

(provide 'org-learn)

;; arch-tag: 

;;; org-learn.el ends here

[-- Attachment #3: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: New module: org-learn, incremental reading
  2009-10-21  8:53 New module: org-learn, incremental reading John Wiegley
@ 2009-10-21 12:23 ` Russell Adams
  2009-10-21 13:58 ` Bill Powell
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Russell Adams @ 2009-10-21 12:23 UTC (permalink / raw)
  To: emacs-orgmode

On Wed, Oct 21, 2009 at 04:53:39AM -0400, John Wiegley wrote:
> The attached file, when loaded, provides two new commands:
>
>   M-x org-smart-reschedule
>   M-x org-agenda-smart-reschedule
>
> The latter being only for the *Org Agenda* buffer.
>
> You should use these commands on a scheduled entry, with state logging  
> enabled for the DONE state.  It then reschedules the item to a future  
> date based on the "SM-5" algorithm and a quality factor you are prompted 
> for.
>
> To summarize the SM-5 algorithm:
>
>   1. After you read an item on the scheduled day, you hit M-x org- 
> smart-reschedule.
>
>   2. You are then asked how well you remember what you just read, from 
> 0-5:
>
>      5 - perfect response
>      4 - correct response after a hesitation
>      3 - correct response recalled with serious difficulty
>      2 - incorrect response; where the correct one seemed easy to recall
>      1 - incorrect response; the correct one remembered
>      0 - complete blackout.
>
>   3. If your answer is 4 or 5, the item will not be repeated.  If it is 
> anything
>      else, the item is rescheduled, to be read again on a future date.
>
>   4. Based on the quality of your response, AND the number of times  
> you've read
>      the item so far, the amount of time being reschedulings will vary.  
> If your
>      retention is good, the gaps grow wider; if it is poor, they grow  
> shorter.
>
>   5. Your "learning data" is kept in a special property called 
> :LEARN_DATA:.  Do
>      not modify this, as it controls how the algorithm reschedules after 
> future
>      repetitions, and based on past quality responses.
>
> More about this algorithm can be read here: 
> http://www.supermemo.com/english/ol/sm2.htm.
>
> This contribution is made in honor of Russell Adams, who drove all the  
> way to New Jersey from Kennedy airport to visit me today, and who  
> brought up the idea of implementing it, based on an earlier proposal by 
> Pere Quintana Segu? (http://article.gmane.org/gmane.emacs.orgmode/17781 
> ).
>
> John
>

John,

That was *fast*. I'll look into moving some of my notes into this.

What do you think regarding the initial setup of "spaced" interval?

Were there a file full of tidbits to digest this way, a way to
pseudo-random scatter them across a few weeks might be useful.

Now I've got to remember my git commands to checkout the latest. ;]

Thanks.

PS. Next time I'll bring my gaming HD and we'll LAN party!



------------------------------------------------------------------
Russell Adams                            RLAdams@AdamsInfoServ.com

PGP Key ID:     0x1160DCB3           http://www.adamsinfoserv.com/

Fingerprint:    1723 D8CA 4280 1EC9 557F  66E8 1154 E018 1160 DCB3

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: New module: org-learn, incremental reading
  2009-10-21  8:53 New module: org-learn, incremental reading John Wiegley
  2009-10-21 12:23 ` Russell Adams
@ 2009-10-21 13:58 ` Bill Powell
  2009-10-21 22:44   ` John Wiegley
  2009-10-24 14:36   ` Richard KLINDA
  2009-10-21 20:26 ` Quintana Seguí, Pere
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 11+ messages in thread
From: Bill Powell @ 2009-10-21 13:58 UTC (permalink / raw)
  To: Org-mode Mode

Wow! This is great! I'm using Anki and Mnemosyne to manage
spaced repetition right now, but integrating this with
org-mode is /awesome/. 

Just one question...

[snip]

>      5 - perfect response
>      4 - correct response after a hesitation
>      3 - correct response recalled with serious difficulty
>      2 - incorrect response; where the correct one seemed easy to recall
>      1 - incorrect response; the correct one remembered
>      0 - complete blackout.
>
>   3. If your answer is 4 or 5, the item will not be repeated.  

In my own experience, material /always/ has to be repeated.
Especially when you're first learning something, those
"perfect" responses will turn real shaky if you wait three
months before you look at the items again. I believe this is
how Anki and Mnemosyne work, too.

Anyhow, I will look at the code, as it's probably easy
enough to tweak, but I just wanted to mention this issue.
Coming back to previous "perfects" after too long and
finding them fuzzy can be quite disappointing. :) 

Thanks again for this!

Bill Powell

-- 
_____________________________________________________________

http://stmarysmessenger.com : New Catholic magazine for kids!
http://wineskinmedia.com : Books and sites crafted with care.
http://billpowellisalive.com : Man found alive with two legs.  
_____________________________________________________________

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: New module: org-learn, incremental reading
  2009-10-21  8:53 New module: org-learn, incremental reading John Wiegley
  2009-10-21 12:23 ` Russell Adams
  2009-10-21 13:58 ` Bill Powell
@ 2009-10-21 20:26 ` Quintana Seguí, Pere
  2009-10-24 14:32 ` Richard KLINDA
  2009-10-25 16:04 ` Huang Tao
  4 siblings, 0 replies; 11+ messages in thread
From: Quintana Seguí, Pere @ 2009-10-21 20:26 UTC (permalink / raw)
  To: John Wiegley; +Cc: Org-mode Mode, Carsten Dominik

Johan, thanks a lot for such a great piece of software. I didn't
expect to have this feature implemented so fast!

I'm very new to this community, but now I'm sure it was a great idea
to invest some time learning Emacs and Org-mode!

The next step will be to learn some Emacs Lisp. But this is tougher, though.

Thank you,

Pere

2009/10/21 John Wiegley <jwiegley@gmail.com>:
> The attached file, when loaded, provides two new commands:
>
>  M-x org-smart-reschedule
>  M-x org-agenda-smart-reschedule
>
> The latter being only for the *Org Agenda* buffer.
>
> You should use these commands on a scheduled entry, with state logging
> enabled for the DONE state.  It then reschedules the item to a future date
> based on the "SM-5" algorithm and a quality factor you are prompted for.
>
> To summarize the SM-5 algorithm:
>
>  1. After you read an item on the scheduled day, you hit M-x
> org-smart-reschedule.
>
>  2. You are then asked how well you remember what you just read, from 0-5:
>
>     5 - perfect response
>     4 - correct response after a hesitation
>     3 - correct response recalled with serious difficulty
>     2 - incorrect response; where the correct one seemed easy to recall
>     1 - incorrect response; the correct one remembered
>     0 - complete blackout.
>
>  3. If your answer is 4 or 5, the item will not be repeated.  If it is
> anything
>     else, the item is rescheduled, to be read again on a future date.
>
>  4. Based on the quality of your response, AND the number of times you've
> read
>     the item so far, the amount of time being reschedulings will vary.  If
> your
>     retention is good, the gaps grow wider; if it is poor, they grow
> shorter.
>
>  5. Your "learning data" is kept in a special property called :LEARN_DATA:.
>  Do
>     not modify this, as it controls how the algorithm reschedules after
> future
>     repetitions, and based on past quality responses.
>
> More about this algorithm can be read here:
> http://www.supermemo.com/english/ol/sm2.htm.
>
> This contribution is made in honor of Russell Adams, who drove all the way
> to New Jersey from Kennedy airport to visit me today, and who brought up the
> idea of implementing it, based on an earlier proposal by Pere Quintana Seguí
> (http://article.gmane.org/gmane.emacs.orgmode/17781).
>
> John
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
>



-- 
http://pere.quintanasegui.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Re: New module: org-learn, incremental reading
  2009-10-21 13:58 ` Bill Powell
@ 2009-10-21 22:44   ` John Wiegley
  2009-10-24 14:36   ` Richard KLINDA
  1 sibling, 0 replies; 11+ messages in thread
From: John Wiegley @ 2009-10-21 22:44 UTC (permalink / raw)
  To: Bill Powell; +Cc: Org-mode Mode

On Oct 21, 2009, at 9:58 AM, Bill Powell wrote:

> In my own experience, material /always/ has to be repeated.
> Especially when you're first learning something, those
> "perfect" responses will turn real shaky if you wait three
> months before you look at the items again. I believe this is
> how Anki and Mnemosyne work, too.

The algorithm had two details that maybe we could make configurable:

  1. If the user's quality answer is <3, restart the OF-Matrix all
     over again, but using the current E-Factor.

  2. If the user's quality answer is >3, stop the repetition cycle.

We could make these numbers be min and max, and configurable, so that  
you could either always repeat, or only restart the OF-Matrix if it's  
below a lower number.

John

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: New module: org-learn, incremental reading
  2009-10-21  8:53 New module: org-learn, incremental reading John Wiegley
                   ` (2 preceding siblings ...)
  2009-10-21 20:26 ` Quintana Seguí, Pere
@ 2009-10-24 14:32 ` Richard KLINDA
  2009-10-25 16:04 ` Huang Tao
  4 siblings, 0 replies; 11+ messages in thread
From: Richard KLINDA @ 2009-10-24 14:32 UTC (permalink / raw)
  To: Org-mode Mode

Excellent, I have been wanting to use this SuperMemo feature for years.
Having it readily available in org mode is just too good to be true.

Thanks,
Richard

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: New module: org-learn, incremental reading
  2009-10-21 13:58 ` Bill Powell
  2009-10-21 22:44   ` John Wiegley
@ 2009-10-24 14:36   ` Richard KLINDA
  1 sibling, 0 replies; 11+ messages in thread
From: Richard KLINDA @ 2009-10-24 14:36 UTC (permalink / raw)
  To: Org-mode Mode

>>>>> Regarding 'Re: New module: org-learn, incremental reading'; Bill Powell adds:


  >> 3. If your answer is 4 or 5, the item will not be repeated.

  > In my own experience, material /always/ has to be repeated.

+1.  Repetition (optimally with ever increasing intervals) is a must.

Richard

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: New module: org-learn, incremental reading
  2009-10-21  8:53 New module: org-learn, incremental reading John Wiegley
                   ` (3 preceding siblings ...)
  2009-10-24 14:32 ` Richard KLINDA
@ 2009-10-25 16:04 ` Huang Tao
  2009-10-25 20:51   ` John Wiegley
  4 siblings, 1 reply; 11+ messages in thread
From: Huang Tao @ 2009-10-25 16:04 UTC (permalink / raw)
  To: Org-mode Mode

Well done! It frees me from the fully hand schedule stuff.

but i got something wrong while launch org-smart-reschedule:

  1. function org-entry-beginning-position and org-entry-end-position
doesn't exist
  2. variable learning-fraction doesn't exist.

I replace the org-entry-[beginning|end]-position with
org-back-to-heading and org-end-of-subtree, change the
learning-fraction to org-learning-fraction to get done(ugly, just
runnable).

Did some one has a better solution? Why I got this, my system is
too old(or new)?
my
 - Emacs version: GNU Emacs 23.1.50.1 (i686-pc-linux-gnu)
 - Org-mode version: 6.31a

Thanks.



On Wed, Oct 21, 2009 at 4:53 PM, John Wiegley <jwiegley@gmail.com> wrote:
> The attached file, when loaded, provides two new commands:
>
>  M-x org-smart-reschedule
>  M-x org-agenda-smart-reschedule
>
> The latter being only for the *Org Agenda* buffer.
>
> You should use these commands on a scheduled entry, with state logging
> enabled for the DONE state.  It then reschedules the item to a future date
> based on the "SM-5" algorithm and a quality factor you are prompted for.
>
> To summarize the SM-5 algorithm:
>
>  1. After you read an item on the scheduled day, you hit M-x
> org-smart-reschedule.
>
>  2. You are then asked how well you remember what you just read, from 0-5:
>
>     5 - perfect response
>     4 - correct response after a hesitation
>     3 - correct response recalled with serious difficulty
>     2 - incorrect response; where the correct one seemed easy to recall
>     1 - incorrect response; the correct one remembered
>     0 - complete blackout.
>
>  3. If your answer is 4 or 5, the item will not be repeated.  If it is
> anything
>     else, the item is rescheduled, to be read again on a future date.
>
>  4. Based on the quality of your response, AND the number of times you've
> read
>     the item so far, the amount of time being reschedulings will vary.  If
> your
>     retention is good, the gaps grow wider; if it is poor, they grow
> shorter.
>
>  5. Your "learning data" is kept in a special property called :LEARN_DATA:.
>  Do
>     not modify this, as it controls how the algorithm reschedules after
> future
>     repetitions, and based on past quality responses.
>
> More about this algorithm can be read here:
> http://www.supermemo.com/english/ol/sm2.htm.
>
> This contribution is made in honor of Russell Adams, who drove all the way
> to New Jersey from Kennedy airport to visit me today, and who brought up the
> idea of implementing it, based on an earlier proposal by Pere Quintana Seguí
> (http://article.gmane.org/gmane.emacs.orgmode/17781).
>
> John
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: New module: org-learn, incremental reading
  2009-10-25 16:04 ` Huang Tao
@ 2009-10-25 20:51   ` John Wiegley
       [not found]     ` <4ae4c751.1438560a.579a.ffffea34@mx.google.com>
  0 siblings, 1 reply; 11+ messages in thread
From: John Wiegley @ 2009-10-25 20:51 UTC (permalink / raw)
  To: Huang Tao; +Cc: Org-mode Mode

On Oct 25, 2009, at 12:04 PM, Huang Tao wrote:

> but i got something wrong while launch org-smart-reschedule:
>
>  1. function org-entry-beginning-position and org-entry-end-position
> doesn't exist
>  2. variable learning-fraction doesn't exist.

org-learn.el depends on the very latest Org-mode from its Git  
repository.

John

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: New module: org-learn, incremental reading
       [not found]     ` <4ae4c751.1438560a.579a.ffffea34@mx.google.com>
@ 2009-10-25 21:49       ` John Wiegley
  2009-10-27 15:47         ` Jonathan Arkell
  0 siblings, 1 reply; 11+ messages in thread
From: John Wiegley @ 2009-10-25 21:49 UTC (permalink / raw)
  To: Richard Riley; +Cc: Org-mode Mode

[-- Attachment #1: Type: text/plain, Size: 240 bytes --]

On Oct 25, 2009, at 5:46 PM, Richard Riley wrote:

> Just trying this and got
>
> org-smart-reschedule: Symbol's value as variable is void:
> learning-fraction
>
> when I enter 0-3. It worked with 5.

Attached is an updated version.

John


[-- Attachment #2: org-learn.el --]
[-- Type: application/octet-stream, Size: 6088 bytes --]

;;; org-learn.el --- Implements SuperMemo's incremental learning algorithm

;; Copyright (C) 2009
;;   Free Software Foundation, Inc.

;; Author: John Wiegley <johnw at gnu dot org>
;; Keywords: outlines, hypermedia, calendar, wp
;; Homepage: http://orgmode.org
;; Version: 6.31trans
;;
;; This file is part of GNU Emacs.
;;
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:

;; The file implements the learning algorithm described at
;; http://supermemo.com/english/ol/sm5.htm, which is a system for reading
;; material according to "spaced repetition".  See
;; http://en.wikipedia.org/wiki/Spaced_repetition for more details.
;;
;; To use, turn on state logging and schedule some piece of information you
;; want to read.  Then in the agenda buffer type

(require 'org)
(eval-when-compile
  (require 'cl)
  (require 'calendar))

(defgroup org-learn nil
  "Options concerning the learning code in Org-mode."
  :tag "Org Learn"
  :group 'org-progress)

(defcustom org-learn-always-reschedule nil
  "If non-nil, always reschedule items, even if retention was \"perfect\"."
  :type 'boolean
  :group 'org-learn)

(defcustom org-learn-fraction 0.5
  "Controls the rate at which EF is increased or decreased.
Must be a number between 0 and 1 (the greater it is the faster
the changes of the OF matrix)."
  :type 'float
  :group 'org-learn)

(defun initial-optimal-factor (n ef)
  (if (= 1 n)
      4
    ef))

(defun get-optimal-factor (n ef of-matrix)
  (let ((factors (assoc n of-matrix)))
    (or (and factors
	     (let ((ef-of (assoc ef (cdr factors))))
	       (and ef-of (cdr ef-of))))
	(initial-optimal-factor n ef))))

(defun set-optimal-factor (n ef of-matrix of)
  (let ((factors (assoc n of-matrix)))
    (if factors
	(let ((ef-of (assoc ef (cdr factors))))
	  (if ef-of
	      (setcdr ef-of of)
	    (push (cons ef of) (cdr factors))))
      (push (cons n (list (cons ef of))) of-matrix)))
  of-matrix)

(defun inter-repetition-interval (n ef &optional of-matrix)
  (let ((of (get-optimal-factor n ef of-matrix)))
    (if (= 1 n)
	of
      (* of (inter-repetition-interval (1- n) ef of-matrix)))))

(defun modify-e-factor (ef quality)
  (if (< ef 1.3)
      1.3
    (+ ef (- 0.1 (* (- 5 quality) (+ 0.08 (* (- 5 quality) 0.02)))))))

(defun modify-of (of q fraction)
  (let ((temp (* of (+ 0.72 (* q 0.07)))))
    (+ (* (- 1 fraction) of) (* fraction temp))))

(defun calculate-new-optimal-factor (interval-used quality used-of
						   old-of fraction)
  "This implements the SM-5 learning algorithm in Lisp.
INTERVAL-USED is the last interval used for the item in question.
QUALITY is the quality of the repetition response.
USED-OF is the optimal factor used in calculation of the last
interval used for the item in question.
OLD-OF is the previous value of the OF entry corresponding to the
relevant repetition number and the E-Factor of the item.
FRACTION is a number belonging to the range (0,1) determining the
rate of modifications (the greater it is the faster the changes
of the OF matrix).

Returns the newly calculated value of the considered entry of the
OF matrix."
  (let (;; the value proposed for the modifier in case of q=5
	(mod5 (/ (1+ interval-used) interval-used))
	;; the value proposed for the modifier in case of q=2
	(mod2 (/ (1- interval-used) interval-used))
	;; the number determining how many times the OF value will
	;; increase or decrease
	modifier)
    (if (< mod5 1.05)
	(setq mod5 1.05))
    (if (< mod2 0.75)
	(setq mod5 0.75))
    (if (> quality 4)
	(setq modifier (1+ (* (- mod5 1) (- quality 4))))
      (setq modifier (- 1 (* (/ (- 1 mod2) 2) (- 4 quality)))))
    (if (< modifier 0.05)
	(setq modifier 0.05))
    (setq new-of (* used-of modifier))
    (if (> quality 4)
	(if (< new-of old-of)
	    (setq new-of old-of)))
    (if (< quality 4)
	(if (> new-of old-of)
	    (setq new-of old-of)))
    (setq new-of (+ (* new-of fraction) (* old-of (- 1 fraction))))
    (if (< new-of 1.2)
	(setq new-of 1.2)
      new-of)))

(defvar initial-repetition-state '(-1 1 2.5 nil))

(defun determine-next-interval (n ef quality of-matrix)
  (assert (> n 0))
  (assert (and (>= quality 0) (<= quality 5)))
  (if (< quality 3)
      (list (inter-repetition-interval n ef) (1+ n) ef nil)
    (let ((next-ef (modify-e-factor ef quality)))
      (setq of-matrix
	    (set-optimal-factor n next-ef of-matrix
				(modify-of (get-optimal-factor n ef of-matrix)
					   quality org-learn-fraction))
	    ef next-ef)
      ;; For a zero-based quality of 4 or 5, don't repeat
      (if (and (>= quality 4)
	       (not org-learn-always-reschedule))
	  (list 0 (1+ n) ef of-matrix)
	(list (inter-repetition-interval n ef of-matrix) (1+ n)
	      ef of-matrix)))))

(defun org-smart-reschedule (quality)
  (interactive "nHow well did you remember the information (on a scale of 0-5)? ")
  (let* ((learn-str (org-entry-get (point) "LEARN_DATA"))
	 (learn-data (or (and learn-str
			      (read learn-str))
			 (copy-list initial-repetition-state)))
	 closed-dates)
    (setq learn-data
	  (determine-next-interval (nth 1 learn-data)
				   (nth 2 learn-data)
				   quality
				   (nth 3 learn-data)))
    (org-entry-put (point) "LEARN_DATA" (prin1-to-string learn-data))
    (if (= 0 (nth 0 learn-data))
	(org-schedule t)
      (org-schedule nil (time-add (current-time)
				  (days-to-time (nth 0 learn-data)))))))

(provide 'org-learn)

;; arch-tag: 

;;; org-learn.el ends here

[-- Attachment #3: Type: text/plain, Size: 2 bytes --]




[-- Attachment #4: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: Re: New module: org-learn, incremental reading
  2009-10-25 21:49       ` John Wiegley
@ 2009-10-27 15:47         ` Jonathan Arkell
  0 siblings, 0 replies; 11+ messages in thread
From: Jonathan Arkell @ 2009-10-27 15:47 UTC (permalink / raw)
  To: John Wiegley; +Cc: Org-mode Mode

[-- Attachment #1: Type: text/plain, Size: 1666 bytes --]

I like where org-learn is going.  Good job.  I am experiencing some issues however (which could easily be me).

If I schedule an item for today, and then do an org-smart-reschedule, it seems that it will always get scheduled for 4 days from now, regardless of either the org-learn-fraction, or my input into org-smart-reschedule.

I would expect that if I enter a 0, it would reschedule the item much sooner than if I entered a 5.  Note that this is on an item that initially have empty LEARN_DATA.

Also, I've attached a patch.  It adds documentation to org-smart-reschedule, and defines an alias to it called "org-learn-reschedule".



-----Original Message-----
From: emacs-orgmode-bounces+jonathana=criticalmass.com@gnu.org [mailto:emacs-orgmode-bounces+jonathana=criticalmass.com@gnu.org] On Behalf Of John Wiegley
Sent: October 25, 2009 3:49 PM
To: Richard Riley
Cc: Org-mode Mode
Subject: [Orgmode] Re: New module: org-learn, incremental reading

On Oct 25, 2009, at 5:46 PM, Richard Riley wrote:

> Just trying this and got
>
> org-smart-reschedule: Symbol's value as variable is void:
> learning-fraction
>
> when I enter 0-3. It worked with 5.

Attached is an updated version.

John


The information contained in this message is confidential. It is intended to be read only by the individual or entity named above or their designee. If the reader of this message is not the intended recipient, you are hereby notified that any distribution of this message, in any form, is strictly prohibited. If you have received this message in error, please immediately notify the sender and delete or destroy any copy of this message.

[-- Attachment #2: org-learn-patch.txt --]
[-- Type: text/plain, Size: 1795 bytes --]

*** c:/Documents and Settings/jonathana/Local Settings/Temporary Internet Files/Content.Outlook/TP585W2O/org-learn (2).el	Sun Oct 25 15:51:03 2009
--- c:/Emacs/my-site-lisp/org-learn.el	Tue Oct 27 09:34:26 2009
***************
*** 157,163 ****
--- 175,196 ----
  	      ef of-matrix)))))
  
  (defun org-smart-reschedule (quality)
+   "Reschedule the item based on how well the user remembered it.
+ 
+ The QUALITY Scale works like this:
+ 
+ 0-2 Means you have forgotten the item.
+ 3-5 Means you have remembered the item.
+ 
+ 0 - Completely forgot. 
+ 1 - Even after seeing the answer, it still took a bit to sink in. 
+ 2 - After seeing the answer, you remembered it. 
+ 3 - It took you awhile, but you finally remembered.
+ 4 - After a little bit of thought you remembered.
+ 5 - You remembered the item really easily."
    (interactive "nHow well did you remember the information (on a scale of 0-5)? ")
+   (when (not (eq major-mode 'org-mode))
+ 	(error "You must be in org-mode to use this!"))
    (let* ((learn-str (org-entry-get (point) "LEARN_DATA"))
  	 (learn-data (or (and learn-str
  			      (read learn-str))
***************
*** 171,178 ****
      (org-entry-put (point) "LEARN_DATA" (prin1-to-string learn-data))
      (if (= 0 (nth 0 learn-data))
  	(org-schedule t)
!       (org-schedule nil (time-add (current-time)
! 				  (days-to-time (nth 0 learn-data)))))))
  
  (provide 'org-learn)
  
--- 204,213 ----
      (org-entry-put (point) "LEARN_DATA" (prin1-to-string learn-data))
      (if (= 0 (nth 0 learn-data))
  	(org-schedule t)
! 	(org-schedule nil (time-add (current-time)
! 				    (days-to-time (nth 0 learn-data)))))))
! 
! (defalias 'org-learn-reschedule 'org-smart-reschedule)
  
  (provide 'org-learn)
  

[-- Attachment #3: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2009-10-27 15:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-21  8:53 New module: org-learn, incremental reading John Wiegley
2009-10-21 12:23 ` Russell Adams
2009-10-21 13:58 ` Bill Powell
2009-10-21 22:44   ` John Wiegley
2009-10-24 14:36   ` Richard KLINDA
2009-10-21 20:26 ` Quintana Seguí, Pere
2009-10-24 14:32 ` Richard KLINDA
2009-10-25 16:04 ` Huang Tao
2009-10-25 20:51   ` John Wiegley
     [not found]     ` <4ae4c751.1438560a.579a.ffffea34@mx.google.com>
2009-10-25 21:49       ` John Wiegley
2009-10-27 15:47         ` Jonathan Arkell

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).