matholroyd-supermemo 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +38 -0
- data/Rakefile +14 -0
- data/lib/sm2.rb +43 -0
- data/supermemo.gemspec +31 -0
- metadata +63 -0
data/README.rdoc
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
= SuperMemo
|
|
2
|
+
|
|
3
|
+
Ruby gem that implements the SM-2 algorithm of SuperMemo. See http://www.supermemo.com/english/ol/sm2.htm for more details.
|
|
4
|
+
|
|
5
|
+
== Install
|
|
6
|
+
|
|
7
|
+
gem install supermemo --sorce http://gems.github.com
|
|
8
|
+
|
|
9
|
+
== Usage
|
|
10
|
+
|
|
11
|
+
=== Variables used
|
|
12
|
+
|
|
13
|
+
q - the Quality of the recall (i.e.. was the item recalled or forgotten), as an integer between 0-5.
|
|
14
|
+
0-2 represent "completely unknown (0)" to "almost remembered (2)"
|
|
15
|
+
3-5 represent "barely remembered (3)" to "instantly remembered (5)"
|
|
16
|
+
|
|
17
|
+
ef - The Easiness Factor of the item being recalled. The smaller the number the harder the item is to remember. For new items this should be set to 2.5.
|
|
18
|
+
|
|
19
|
+
i - The scheduled Interval for the item to be recalled, in days. That is, how many days until the item should be recalled to retain it.
|
|
20
|
+
|
|
21
|
+
n - The nth iteration of the recall. An integer, starting at 1 for the first time the item is recalled.
|
|
22
|
+
|
|
23
|
+
For more background on these variables, see http://www.supermemo.com/english/ol/sm2.htm
|
|
24
|
+
|
|
25
|
+
=== Code
|
|
26
|
+
|
|
27
|
+
i, ef, n = SuperMemo::SM2.i_and_ef_and_n(n, q, prev_i, prev_ef = 2.5)
|
|
28
|
+
|
|
29
|
+
This is the main algorithm. Use it to figure out the next interval until the item should be recalled (i), the change in the easiness factor (ef), and new value for n.
|
|
30
|
+
|
|
31
|
+
do_repeat = SuperMemo::SM2.should_repeat_today(q)
|
|
32
|
+
|
|
33
|
+
As described in the SM-2 algorithm, anything that is not recalled or recalled with difficulty should be repeated again at the end of the day's learning session. This method takes the q value of an item and returns whether it should be repeated.
|
|
34
|
+
|
|
35
|
+
== Notes
|
|
36
|
+
|
|
37
|
+
Currently this gem only includes the SM-2 version of the SuperMemo algorithm. Although more recent versions of the SuperMemo algorithm exist, some popular open source and commercial alternatives to SuperMemo (such as Mnemosyne) base their algorithms on the SM-2 algorithm, as they judge it a superior algorithm to the more recent iterations. The author of Mnemosyne (the leading open source alternative) makes the point that there is a conflict of interest underlying commercial products like SuperMemo, in that companies have a vested interest in claiming the newer algorithms are better regardless of whether they actually are.
|
|
38
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'rake'
|
|
3
|
+
require 'echoe'
|
|
4
|
+
|
|
5
|
+
Echoe.new('supermemo', '0.1.0') do |p|
|
|
6
|
+
p.description = 'The SuperMemo (version SM-2) algorithm in ruby'
|
|
7
|
+
p.url = 'http://github.com/matholroyd/supermemo'
|
|
8
|
+
p.author = 'Mat Holroyd'
|
|
9
|
+
p.email = 'matholroyd+supermemo@gmail.com'
|
|
10
|
+
p.ignore_pattern = ['tmp/*', 'script/*']
|
|
11
|
+
p.development_dependencies = []
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
data/lib/sm2.rb
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module SuperMemo
|
|
2
|
+
|
|
3
|
+
# This class includes the algorithms as used by SuperMemo 2 (typically referred to
|
|
4
|
+
# as SM2). See the README for more information.
|
|
5
|
+
class SM2
|
|
6
|
+
|
|
7
|
+
# This is the main algorithm, used to calculate the new i, ef, and n factors.
|
|
8
|
+
# Note that EF defaults to 2.5 (for items that are new)
|
|
9
|
+
def self.i_and_ef_and_n(n, q, prev_i, prev_ef = 2.5)
|
|
10
|
+
if q < 3
|
|
11
|
+
n = 1
|
|
12
|
+
ef = prev_ef
|
|
13
|
+
else
|
|
14
|
+
n += 1
|
|
15
|
+
ef = new_ef(prev_ef, q)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
case n
|
|
19
|
+
when 1
|
|
20
|
+
i = 1
|
|
21
|
+
when 2
|
|
22
|
+
i = 6
|
|
23
|
+
else
|
|
24
|
+
i = prev_i * ef
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
[i, ef, n]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Items that were forgotten or almost forgotten (scored a grade < 4) should be recalled on the
|
|
31
|
+
# current day until the grade goes to 4 or more.
|
|
32
|
+
def self.should_repeat_today(q)
|
|
33
|
+
q < 4
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
def self.new_ef(ef_old, q)
|
|
39
|
+
ef = ef_old - 0.8 + (0.28*q) - (0.02*q*q)
|
|
40
|
+
ef < 1.3 ? 1.3 : ef
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
data/supermemo.gemspec
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |s|
|
|
4
|
+
s.name = %q{supermemo}
|
|
5
|
+
s.version = "0.1.0"
|
|
6
|
+
|
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
|
8
|
+
s.authors = ["Mat Holroyd"]
|
|
9
|
+
s.date = %q{2009-04-07}
|
|
10
|
+
s.description = %q{The SuperMemo (version SM-2) algorithm in ruby}
|
|
11
|
+
s.email = %q{matholroyd+supermemo@gmail.com}
|
|
12
|
+
s.extra_rdoc_files = ["lib/sm2.rb", "README.rdoc"]
|
|
13
|
+
s.files = ["lib/sm2.rb", "Manifest", "Rakefile", "README.rdoc", "supermemo.gemspec"]
|
|
14
|
+
s.has_rdoc = true
|
|
15
|
+
s.homepage = %q{http://github.com/matholroyd/supermemo}
|
|
16
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Supermemo", "--main", "README.rdoc"]
|
|
17
|
+
s.require_paths = ["lib"]
|
|
18
|
+
s.rubyforge_project = %q{supermemo}
|
|
19
|
+
s.rubygems_version = %q{1.3.1}
|
|
20
|
+
s.summary = %q{The SuperMemo (version SM-2) algorithm in ruby}
|
|
21
|
+
|
|
22
|
+
if s.respond_to? :specification_version then
|
|
23
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
24
|
+
s.specification_version = 2
|
|
25
|
+
|
|
26
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
|
27
|
+
else
|
|
28
|
+
end
|
|
29
|
+
else
|
|
30
|
+
end
|
|
31
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: matholroyd-supermemo
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Mat Holroyd
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2009-04-07 00:00:00 -07:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies: []
|
|
15
|
+
|
|
16
|
+
description: The SuperMemo (version SM-2) algorithm in ruby
|
|
17
|
+
email: matholroyd+supermemo@gmail.com
|
|
18
|
+
executables: []
|
|
19
|
+
|
|
20
|
+
extensions: []
|
|
21
|
+
|
|
22
|
+
extra_rdoc_files:
|
|
23
|
+
- lib/sm2.rb
|
|
24
|
+
- README.rdoc
|
|
25
|
+
files:
|
|
26
|
+
- lib/sm2.rb
|
|
27
|
+
- Manifest
|
|
28
|
+
- Rakefile
|
|
29
|
+
- README.rdoc
|
|
30
|
+
- supermemo.gemspec
|
|
31
|
+
has_rdoc: true
|
|
32
|
+
homepage: http://github.com/matholroyd/supermemo
|
|
33
|
+
post_install_message:
|
|
34
|
+
rdoc_options:
|
|
35
|
+
- --line-numbers
|
|
36
|
+
- --inline-source
|
|
37
|
+
- --title
|
|
38
|
+
- Supermemo
|
|
39
|
+
- --main
|
|
40
|
+
- README.rdoc
|
|
41
|
+
require_paths:
|
|
42
|
+
- lib
|
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: "0"
|
|
48
|
+
version:
|
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: "1.2"
|
|
54
|
+
version:
|
|
55
|
+
requirements: []
|
|
56
|
+
|
|
57
|
+
rubyforge_project: supermemo
|
|
58
|
+
rubygems_version: 1.2.0
|
|
59
|
+
signing_key:
|
|
60
|
+
specification_version: 2
|
|
61
|
+
summary: The SuperMemo (version SM-2) algorithm in ruby
|
|
62
|
+
test_files: []
|
|
63
|
+
|