repetition 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 395411bf8918658d462f941a292cf0ed689987505f30c13e31843fad1e45e38a
4
- data.tar.gz: bc4232618f5ebde02ee0b6c63daf4b21217a43bb9aa29a8230279f374bd9d67c
3
+ metadata.gz: a8f83e5a3642ef6323489f00d79859b2641e739c68f2a09dd3fddf0abc17ffdd
4
+ data.tar.gz: acfb2c388061a6bb2ce61610cddcecd723ad80e5a0799dc34d01d60b1f52e6d3
5
5
  SHA512:
6
- metadata.gz: b0b276d0d13d1515c656b967a397ad89bcf50925c66920a7f1daf65eda1ef8136b021e44ed6751b748dc2da4b9db7a9fa8d0a2037cc3f578a431729448ab8276
7
- data.tar.gz: e1bb3c765debf1b8b1acafdb75e9477581d36d9ba4d062c408d1e31d63a164088798cf9a9c76a740fb89fab9fb7382bc75198c12c8219b9331cc560962d4f7a7
6
+ metadata.gz: b7bc7a4f0c11835667cb55e131e169b7cee5807f861299af27dc2a37de816d79931aa2bc9c0c3d8c5da77a247665e21a59ffb36eb36396f0393b793c6dde7c5a
7
+ data.tar.gz: d443112a976d1561887bc4fab0614999fe4c0e4d20107fd01fcef4766806f5fe01b9d2e79a6746ba0956430de6e6cab5e7122a4034e1a6f460adcf8a5ff5fd13
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ### Fixed
10
+ - Fix interval calculation bug
11
+
9
12
  ## [2.0.0] - 2018-08-08
10
13
  ### Changed
11
14
  - Move from module to class implementation
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Repetition
2
2
 
3
- Spaced repetition module which can be used as a mixin in Ruby apps. SuperMemo 2 is used as a repetition algorithm.
3
+ [![Build Status](https://img.shields.io/travis/dankimio/repetition.svg?style=flat)](https://travis-ci.org/dankimio/repetition)
4
+ [![Gem Version](https://img.shields.io/gem/v/repetition.svg?style=flat&color=brightgreen)](https://rubygems.org/gems/repetition)
5
+ [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://raw.githubusercontent.com/dankimio/repetition/master/LICENSE.TXT)
6
+
7
+ Spaced repetition algorithm for scheduling flashcard repetitions. SuperMemo 2 is used as a repetition algorithm.
4
8
 
5
9
  ## Installation
6
10
 
@@ -1,70 +1 @@
1
- #
2
- # The Repetition module uses the Super Memo method to determine when to next
3
- # review an item. The quality values are as follows:
4
- #
5
- # 5 - perfect response
6
- # 4 - correct response after a hesitation
7
- # 3 - correct response recalled with serious difficulty
8
- # 2 - incorrect response; where the correct one seemed easy to recall
9
- # 1 - incorrect response; the correct one remembered
10
- # 0 - complete blackout
11
- #
12
- # Find out more here: https://www.supermemo.com/english/ol/sm2.htm
13
- #
14
-
15
- require 'date'
16
-
17
- module Repetition
18
- class Flashcard
19
- attr_reader :easiness_factor, :interval, :repetitions
20
-
21
- def initialize(easiness_factor: 2.5, interval: 0, repetitions: 0)
22
- @easiness_factor = easiness_factor
23
- @interval = interval
24
- @repetitions = repetitions
25
- end
26
-
27
- def recall(quality)
28
- raise ArgumentError, 'Invalid quality of recall. Should be in range from 0 to 5.' unless (0..5).cover?(quality)
29
-
30
- if quality < 3
31
- # An incorrect recall is reset back to the beginning
32
- @repetitions = 0
33
- @interval = 0
34
- elsif quality == 3
35
- # The item was correctly recalled but should be tested again quickly
36
- @interval = 0
37
- else
38
- # The item was correctly recalled and we can review later on
39
- @repetitions += 1
40
-
41
- case @repetitions
42
- when 1
43
- @interval = 1
44
- when 2
45
- @interval = 6
46
- else
47
- @easiness_factor = calculate_easiness_factor(@easiness_factor, quality)
48
- @interval = interval * easiness_factor
49
- end
50
- end
51
-
52
- due_on
53
- end
54
-
55
- def due_on
56
- today + @interval
57
- end
58
-
59
- private
60
-
61
- def today
62
- @today ||= Date.today
63
- end
64
-
65
- def calculate_easiness_factor(easiness_factor, quality)
66
- result = easiness_factor - 0.8 + (0.28 * quality) - (0.02 * quality * quality)
67
- result < 1.3 ? 1.3 : result
68
- end
69
- end
70
- end
1
+ require 'repetition/flashcard'
@@ -0,0 +1,70 @@
1
+ #
2
+ # The Repetition module uses the Super Memo method to determine when to next
3
+ # review an item. The quality values are as follows:
4
+ #
5
+ # 5 - perfect response
6
+ # 4 - correct response after a hesitation
7
+ # 3 - correct response recalled with serious difficulty
8
+ # 2 - incorrect response; where the correct one seemed easy to recall
9
+ # 1 - incorrect response; the correct one remembered
10
+ # 0 - complete blackout
11
+ #
12
+ # Find out more here: https://www.supermemo.com/english/ol/sm2.htm
13
+ #
14
+
15
+ require 'date'
16
+
17
+ module Repetition
18
+ class Flashcard
19
+ attr_reader :easiness_factor, :interval, :repetitions
20
+
21
+ def initialize(easiness_factor: 2.5, interval: 0, repetitions: 0)
22
+ @easiness_factor = easiness_factor
23
+ @interval = interval
24
+ @repetitions = repetitions
25
+ end
26
+
27
+ def recall(quality)
28
+ raise ArgumentError, 'Invalid quality of recall. Should be in range from 0 to 5.' unless (0..5).cover?(quality)
29
+
30
+ if quality < 3
31
+ # An incorrect recall is reset back to the beginning
32
+ @repetitions = 0
33
+ @interval = 0
34
+ elsif quality == 3
35
+ # The item was correctly recalled but should be tested again quickly
36
+ @interval = 0
37
+ else
38
+ # The item was correctly recalled and we can review later on
39
+ @repetitions += 1
40
+
41
+ case @repetitions
42
+ when 1
43
+ @interval = 1
44
+ when 2
45
+ @interval = 6
46
+ else
47
+ @easiness_factor = calculate_easiness_factor(@easiness_factor, quality)
48
+ @interval = @interval * @easiness_factor
49
+ end
50
+ end
51
+
52
+ due_on
53
+ end
54
+
55
+ def due_on
56
+ today + @interval
57
+ end
58
+
59
+ private
60
+
61
+ def today
62
+ @today ||= Date.today
63
+ end
64
+
65
+ def calculate_easiness_factor(easiness_factor, quality)
66
+ result = easiness_factor - 0.8 + (0.28 * quality) - (0.02 * quality * quality)
67
+ result < 1.3 ? 1.3 : result
68
+ end
69
+ end
70
+ end
@@ -1,3 +1,3 @@
1
1
  module Repetition
2
- VERSION = '2.0.0'
2
+ VERSION = '2.0.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repetition
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Kim
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-08 00:00:00.000000000 Z
11
+ date: 2018-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,6 +70,7 @@ files:
70
70
  - bin/console
71
71
  - bin/setup
72
72
  - lib/repetition.rb
73
+ - lib/repetition/flashcard.rb
73
74
  - lib/repetition/version.rb
74
75
  - repetition.gemspec
75
76
  homepage: http://github.com/danyakim/repetition