The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   AppleScripting Omni Apps (http://forums.omnigroup.com/forumdisplay.php?f=46)
-   -   Spaced repetition system for OmniOutliner 3 (http://forums.omnigroup.com/showthread.php?t=30911)

matt999 2013-10-10 03:48 PM

Spaced repetition system for OmniOutliner 3
 
I'm sure this could be accomplished a lot more efficiently, but here's my attempt to add spaced repetition functionality to OmniOutliner 3. The goal is more efficient memorization using the [URL="http://www.supermemo.com/english/ol/sm2.htm"]SM-2/SuperMemo algorithm[/URL]. (I hope I implemented the formula correctly). Flashcard programs like Anki and Mnemosyne are great, but it's tough to see the context of what you're learning, and in law context is very important. Using OmniOutliner, the row text can serve as a question and the note text as the answer. Columns 3, 4, 5, and 6 are used to store the information about past and future repetitions.

[IMG]http://www.lawschoolmatt.com/filespot/images/2013-10-10_00-04-21.png[/IMG]



[CODE]tell application "OmniOutliner"
-- columns:
-- 1 is checkbox (unused)
-- 2 is for content (questions in the row; answers as comments)
-- 3 is quality
-- 4 is due
-- 5 is numReps
-- 6 is EF
set baseEaseFactor to 1.3
set i to value of cell 5 of selected row of front document -- number of repetitions thus far
set q to value of cell 3 of selected row of front document -- Get quality #
-- Set existing easiness factor...
if value of cell 6 of selected row of front document contains "" then
set value of cell 6 of selected row of front document to baseEaseFactor as text
set oldEF to baseEaseFactor
else
set oldEF to value of cell 6 of selected row of front document -- Get oldEF
end if
-- If there have been no reps:
if i as integer is equal to 0 then
set nextDue to do shell script "date -v+0d +%Y-%m-%d" as string
set value of cell 4 of selected row of front document to nextDue as string
set value of cell 5 of selected row of front document to "1" as string
set value of cell 6 of selected row of front document to baseEaseFactor as string
return
-- If there have been 2 reps:
else if i as integer is equal to 1 then
set i to i + 1
set value of cell 5 of selected row of front document to i as string
set dueCellValue to do shell script "date -v+1d +%Y-%m-%d" as string
set value of cell 4 of selected row of front document to dueCellValue as string
return
else if i as integer is equal to 2 then
set nextDue to do shell script "date -v+6d +%Y-%m-%d" as string
set value of cell 4 of selected row of front document to nextDue as string
set value of cell 5 of selected row of front document to "3" as string
set value of cell 6 of selected row of front document to baseEaseFactor as string
return
else -- all other numbers
set value of cell 5 of selected row of front document to i + 1 as string
set newEF to oldEF - 0.8 + 0.28 * q - 0.02 * q * q
if newEF is less than 1.3 then
set newEF to 1.3
end if
if newEF is greater than or equal to 2.5 then
set newEF to 2.5
end if
set value of cell 6 of selected row of front document to newEF as string
if q > 0 then
set nextDue to (i * (i - 1) * newEF) as integer
set dueCellValue to do shell script "date -v+" & nextDue & "d +%Y-%m-%d"
set value of cell 4 of selected row of front document to dueCellValue as string
set i to i + 1
set value of cell 5 of selected row of front document to i as string
else
set nextDue to do shell script "date -v+0d +%Y-%m-%d" as string
set value of cell 4 of selected row of front document to nextDue as string
set value of cell 5 of selected row of front document to "0" as string
end if
end if
end tell[/CODE]

I've got more written up about this on [URL="http://www.lawschoolmatt.com/uncategorized/popclip-supermemo"]my site[/URL], along with simpler spaced repetition routines for some other software (VoodooPad and EagleFiler).

matt999 2013-10-13 07:06 AM

A couple of improvements
 
I've made a couple of improvements, including a prompt for the grade you give yourself on a given question, and conditional formatting. Rows scored 0 to 4 in the grade column now appear in black. I'm not very good at scripting OmniOutliner, so there was a lot of trial and error involved here until I came up with something that worked. Please feel free to suggest or make changes.

[CODE]tell application "OmniOutliner" -- add Professional if you have the pro version; I only have the standard version.
-- columns:
-- 1 is checkbox (unused)
-- 2 is for content (questions in the row; answers as comments)
-- 3 is quality
-- 4 is due
-- 5 is numReps
-- 6 is EF


set value of cell "0-6" of selected row of front document to the text returned of (display dialog "Grade 0-6 " default answer "3")


set the state of cell "Question?" of selected row of front document to checked

set baseEaseFactor to 1.3
set i to value of cell 5 of selected row of front document -- number of repetitions thus far
set q to value of cell 3 of selected row of front document -- Get quality #
-- Set existing easiness factor...
if value of cell 6 of selected row of front document contains "" then
set value of cell 6 of selected row of front document to baseEaseFactor as text
set oldEF to baseEaseFactor
else
set oldEF to value of cell 6 of selected row of front document -- Get oldEF
end if
-- If there have been no reps:
if i as integer is equal to 0 then
set nextDue to do shell script "date -v+0d +%Y-%m-%d" as string
set value of cell 4 of selected row of front document to nextDue as string
set value of cell 5 of selected row of front document to "1" as string
set value of cell 6 of selected row of front document to baseEaseFactor as string
return
-- If there have been 2 reps:
else if i as integer is equal to 1 then
set i to i + 1
set value of cell 5 of selected row of front document to i as string
set dueCellValue to do shell script "date -v+1d +%Y-%m-%d" as string
set value of cell 4 of selected row of front document to dueCellValue as string
return
else if i as integer is equal to 2 then
set nextDue to do shell script "date -v+6d +%Y-%m-%d" as string
set value of cell 4 of selected row of front document to nextDue as string
set value of cell 5 of selected row of front document to "3" as string
set value of cell 6 of selected row of front document to baseEaseFactor as string
return
else -- all other numbers
set value of cell 5 of selected row of front document to i + 1 as string
set newEF to oldEF - 0.8 + 0.28 * q - 0.02 * q * q
if newEF is less than 1.3 then
set newEF to 1.3
end if
if newEF is greater than or equal to 2.5 then
set newEF to 2.5
end if
set value of cell 6 of selected row of front document to newEF as string
if q > 0 then
set nextDue to (i * (i - 1) * newEF) as integer
set dueCellValue to do shell script "date -v+" & nextDue & "d +%Y-%m-%d"
set value of cell 4 of selected row of front document to dueCellValue as string
set i to i + 1
set value of cell 5 of selected row of front document to i as string
else
set nextDue to do shell script "date -v+0d +%Y-%m-%d" as string
set value of cell 4 of selected row of front document to nextDue as string
set value of cell 5 of selected row of front document to "0" as string
end if
end if
end tell

delay 2
-- new part to format rows graded less than 4:
tell application "OmniOutliner" -- add Professional if you have the pro version; I only have the standard version.
tell front document
repeat with theRow in (every row whose state of cell "Question?" is checked)
set testCell to value of cell "0-6" of theRow
if the testCell ≥ 4 then
tell style of theRow
set value of attribute "font-fill" to {0, 0, 0} -- RGB for black
end tell
else
tell style of theRow
set value of attribute "font-fill" to {55838, 634, 634} -- RGB for red
end tell
end if
end repeat
end tell
end tell
[/CODE]


All times are GMT -8. The time now is 03:42 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.