Documentation
¶
Overview ¶
A model for spaced repetition system learning.
This package maintains a database of problems, and some notions of intervals and a bit of history in order to allow them to be used for spaced repetition learning.
The key type is the `T` which is associated with a single database file.
A given `Problem` is simply two text strings, a question and an answer. It is up to the user of this package to determine what these mean. It could be as simple as text to display to the user, or some encoded data to determine the correct answer.
The client of this package should be able to ask questions, determine if the answer is correct, and return a 1-4 rating of how well the user answered the question. In some cases, it may only make sense to return either a 1 for an incorrect answer, or a 4 for a correct answer.
Index ¶
- type Bucket
- type Counts
- type Populator
- type Problem
- type T
- func (t *T) Begin() (Populator, error)
- func (t *T) Close() error
- func (t *T) GetCounts() (*Counts, error)
- func (t *T) GetNew() (*Problem, error)
- func (t *T) GetNexts(count int) ([]*Problem, error)
- func (t *T) Kind() string
- func (t *T) TestSetNowFunc(now func() time.Time)
- func (t *T) Update(prob *Problem, factor int) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket struct { Name string // Short description of this bucket. Count int // The number of problems in this bucket. }
A Bucket is a single histogram bucket describing the number of problems of a given category.
type Counts ¶
type Counts struct { // The number of "Active" problems. Something is considered // active if it is due for learning. Active int // The number of problems that are being learned, but aren't // ready to be asked again. Later int // The number of problems the user has never been shown Unlearned int // Counts of all of the problems, groups into histogram // buckets based on the learning interval of the problem. The // bucket names are a short description of the interval Buckets []Bucket }
Counts contains statistics about the current state of problems.
type Populator ¶
type Populator struct {
// contains filtered or unexported fields
}
A Populator wraps a database transaction to be able to populate a database with problems to learn. The database should not otherwise be used while this is opened.
func (Populator) Add ¶
Add adds a single unlearned problem to the given store.
func (Populator) Commit ¶
Commit finishes adding problems to the store, by committing the database transaction.
type Problem ¶
type Problem struct { Question string // The question to be asked. Answer string // The correct answer. Next time.Time // When to next ask this question. Interval time.Duration // Current interval to next question // contains filtered or unexported fields }
A problem is a single problem retrieved.
type T ¶
type T struct {
// contains filtered or unexported fields
}
func Create ¶
Create creates a new store at the given path. Will return an error if the database has already been created. The `kind` is a string that can be used later to determine what kind of user interaction to use (and that defines the interpretation of the problems).
func (*T) GetCounts ¶
GetCounts retrieves statistics about the problems available.
func (*T) GetNew ¶
Get a problem that hasn't started being learned. The interval and next will be set appropriately for a new problem. If there are no new problems, the result will be (nil, nil). TODO: Set the interval based on a configurable value, as the default depends on the problem types.
func (*T) GetNexts ¶
GetNexts queries for `count` upcoming problems that are ready to be asked. Will return an array of problems, with element 0 being the next problem that should be asked.
func (*T) TestSetNowFunc ¶
For debug and testing, override the query for the current time with something that is configurable.