Documentation
¶
Index ¶
- Constants
- Variables
- type Card
- type CardWithStats
- type Deck
- type DeckManager
- type DeckStats
- type Ebisu
- type IntervalSnapshot
- type OutputFormat
- type Rater
- type RatingType
- type ReviewScore
- type ReviewSession
- func (s *ReviewSession) Again() error
- func (s *ReviewSession) CorrectAnswer() string
- func (s *ReviewSession) Left() int
- func (s *ReviewSession) Next() string
- func (s *ReviewSession) Rate(rating float64) error
- func (s *ReviewSession) RatingType() RatingType
- func (s *ReviewSession) Sides() []string
- func (s *ReviewSession) StartedAt() time.Time
- func (s *ReviewSession) Total() int
- type SRS
- type SRSAlgorithm
- type Stats
- type StatsSaveFunc
- type StatsStore
- type Supermemo2
- type Supermemo2Plus
- func (sm *Supermemo2Plus) Advance(rating float64) float64
- func (sm *Supermemo2Plus) Less(other SRSAlgorithm) bool
- func (sm *Supermemo2Plus) MarshalJSON() ([]byte, error)
- func (sm *Supermemo2Plus) NextReviewAt() time.Time
- func (sm *Supermemo2Plus) PercentOverdue() float64
- func (sm *Supermemo2Plus) UnmarshalJSON(b []byte) error
- type Supermemo2PlusCustom
Constants ¶
const ( // OutputFormatOrg defines pretty printed org output. OutputFormatOrg OutputFormat = iota // OutputFormatHTML defines html output. OutputFormatHTML // DeckPropertyRater defines deck's org-mode property for the rater DeckPropertyRater = "RATER" // DeckPropertyAlgorithm defines deck's org-mode property for the // algorithm DeckPropertyAlgorithm = "ALGORITHM" // DeckPropertyPerReview defines deck's org-mode property for the // per review amount DeckPropertyPerReview = "PER_REVIEW" // DeckPropertySides defines deck's org-mode property for the side // names DeckPropertySides = "SIDES" )
const ( // SRSSupermemo2 represents Supermemo2 algorithm SRSSupermemo2 SRS = "sm2" // SRSSupermemo2Plus represents Supermemo2Plus algorithm SRSSupermemo2Plus = "sm2+" // SRSSupermemo2PlusCustom represents Supermemo2PlusCustom algorithm SRSSupermemo2PlusCustom = "sm2+c" // SRSEbisu represents Ebisu algorithm SRSEbisu = "ebisu" )
Variables ¶
var ErrNotFound = errors.New("deck not found")
ErrNotFound represents error returned for requests for non-existing deck.
Functions ¶
This section is empty.
Types ¶
type Card ¶
type Card struct { Question string `json:"card"` RawQuestion string `json:"raw_card"` Sides []string `json:"-"` }
Card represents a single card in a Deck. Each card may have multiple sides (answers).
type Deck ¶
type Deck struct { Name string Cards []Card Algorithm SRS RatingType RatingType PerReview int Sides []string // contains filtered or unexported fields }
Deck represents a named collection of the cards to review.
type DeckManager ¶
type DeckManager struct {
// contains filtered or unexported fields
}
DeckManager manages set of decks.
func NewDeckManager ¶
func NewDeckManager(path string, db StatsStore, outFormat OutputFormat) (*DeckManager, error)
NewDeckManager constructs a new DeckManager by reading all decks from a given folder using provided store.
func (DeckManager) DeckStats ¶
func (dm DeckManager) DeckStats(deckName string) ([]CardWithStats, error)
DeckStats returns card stats for a given deck name.
func (DeckManager) ReviewDecks ¶
func (dm DeckManager) ReviewDecks() ([]DeckStats, error)
ReviewDecks returns stats for available decks.
func (DeckManager) ReviewSession ¶
func (dm DeckManager) ReviewSession(deckName string) (*ReviewSession, error)
ReviewSession initiates a new ReviewSession for a given deck name.
type DeckStats ¶
type DeckStats struct { Name string `json:"name"` CardsReady int `json:"cards_ready"` NextReviewAt time.Time `json:"next_review_at"` }
DeckStats stores overview stats for a Deck.
type Ebisu ¶
type Ebisu struct { LastReviewedAt time.Time Alpha float64 Beta float64 Interval float64 Historical []IntervalSnapshot }
Ebisu implements ebisu SSR algorithm.
func (*Ebisu) Less ¶
func (eb *Ebisu) Less(other SRSAlgorithm) bool
Less defines card order for the review.
func (*Ebisu) MarshalJSON ¶
MarshalJSON implements json.Marshaller for Ebisu
func (*Ebisu) NextReviewAt ¶
NextReviewAt returns next review timestamp for a card.
func (*Ebisu) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaller for Ebisu
type IntervalSnapshot ¶
type IntervalSnapshot struct { Timestamp int64 `json:"ts"` Interval float64 `json:"interval"` Factor float64 `json:"factor"` }
IntervalSnapshot records historical changes of the Interval.
type OutputFormat ¶
type OutputFormat int
OutputFormat defines output type produces during org file parsing.
type Rater ¶
type Rater interface {
Rate(question string, score ReviewScore) float64
}
Rater rates review attempt based on amount of mistakes. Rating should be within [0, 1] range.
func HarshRater ¶
func HarshRater() Rater
HarshRater returns miss count based Rater. Miss counter will increase for each "again" score. Rating declines really fast and even 1 mistake results in 0.59 rating.
func TableRater ¶
func TableRater() Rater
TableRater returns Rater implementation with following the conversion table: again => 0 hard => 0.2 good => 0.6 easy => 1.0
type RatingType ¶
type RatingType string
RatingType defines types of review rating options.
const ( // RatingTypeAuto defines auto rated review option. RatingTypeAuto RatingType = "auto" // RatingTypeSelf defines self rated review option. RatingTypeSelf RatingType = "self" )
type ReviewScore ¶
type ReviewScore int
ReviewScore defines grade for review attempts. Rater uses scores to calculate rating in range from [0, 1].
const ( // ReviewScoreAgain defines "again" score. ReviewScoreAgain ReviewScore = iota // ReviewScoreHard defines "hard" score. ReviewScoreHard // ReviewScoreGood defines "good" score. ReviewScoreGood // ReviewScoreEasy defines "easy" score. ReviewScoreEasy )
type ReviewSession ¶
type ReviewSession struct {
// contains filtered or unexported fields
}
ReviewSession contains parameters for a Deck review sessions.
func NewReviewSession ¶
func NewReviewSession(cards []CardWithStats, sides []string, rt RatingType, statsSaver StatsSaveFunc) *ReviewSession
NewReviewSession constructs a new ReviewSession for a given set of cards. Rating calculation will be performed using provided rater. Provided StatsSaveFunc will be used for stats updates post review.
func (*ReviewSession) Again ¶
func (s *ReviewSession) Again() error
Again re-queues current card back for review.
func (*ReviewSession) CorrectAnswer ¶
func (s *ReviewSession) CorrectAnswer() string
CorrectAnswer returns correct answer for a current reviewed card.
func (*ReviewSession) Left ¶
func (s *ReviewSession) Left() int
Left returns amount of cards left to review.
func (*ReviewSession) Next ¶
func (s *ReviewSession) Next() string
Next returns current card to review. Same card will be return until review is attempted via Answer call.
func (*ReviewSession) Rate ¶
func (s *ReviewSession) Rate(rating float64) error
Rate assign rating to a current card and removes it from the queue if rating > 0.
func (*ReviewSession) RatingType ¶
func (s *ReviewSession) RatingType() RatingType
RatingType returns type of rating to be used for the review session.
func (*ReviewSession) Sides ¶
func (s *ReviewSession) Sides() []string
Sides returns side names from the reviewed deck.
func (*ReviewSession) StartedAt ¶
func (s *ReviewSession) StartedAt() time.Time
StartedAt returns start time of the review session.
func (*ReviewSession) Total ¶
func (s *ReviewSession) Total() int
Total returns amount of cards in the session.
type SRSAlgorithm ¶
type SRSAlgorithm interface { json.Marshaler json.Unmarshaler // Advance advances supermemo state for a card. Advance(rating float64) (interval float64) // NextReviewAt returns next review timestamp for a card. NextReviewAt() time.Time // Less defines card order for the review. Less(other SRSAlgorithm) bool }
SRSAlgorithm calculates review intervals
type Stats ¶
type Stats struct {
SRSAlgorithm
}
Stats store SM2+ parameters for a Card.
type StatsSaveFunc ¶
type StatsSaveFunc func(card *CardWithStats) error
StatsSaveFunc persists stats updates.
type StatsStore ¶
type StatsStore interface { io.Closer // RangeStats iterates over all stats in a Store. DB records will be boxed to provide algoritm. RangeStats(deck string, srs SRS, rangeFunc func(card string, stats *Stats) bool) error // SaveStats saves stats for a card. SaveStats(deck string, card string, stats *Stats) error }
StatsStore defines storage interface that is used for storing review stats.
func OpenBoltStore ¶
func OpenBoltStore(filename string) (StatsStore, error)
OpenBoltStore returns a new StatsStore implemented on top of BoltDB.
type Supermemo2 ¶
type Supermemo2 struct { LastReviewedAt time.Time Interval float64 Easiness float64 Correct int Total int Historical []IntervalSnapshot }
Supermemo2 calculates review intervals using SM2 algorithm
func NewSupermemo2 ¶
func NewSupermemo2() *Supermemo2
NewSupermemo2 returns a new Supermemo2 instance
func (*Supermemo2) Advance ¶
func (sm *Supermemo2) Advance(rating float64) float64
Advance advances supermemo state for a card.
func (*Supermemo2) Less ¶
func (sm *Supermemo2) Less(other SRSAlgorithm) bool
Less defines card order for the review.
func (*Supermemo2) MarshalJSON ¶
func (sm *Supermemo2) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaller for Supermemo2
func (*Supermemo2) NextReviewAt ¶
func (sm *Supermemo2) NextReviewAt() time.Time
NextReviewAt returns next review timestamp for a card.
func (*Supermemo2) UnmarshalJSON ¶
func (sm *Supermemo2) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaller for Supermemo2
type Supermemo2Plus ¶
type Supermemo2Plus struct { LastReviewedAt time.Time Difficulty float64 Interval float64 Historical []IntervalSnapshot }
Supermemo2Plus calculates review intervals using SM2+ algorithm
func NewSupermemo2Plus ¶
func NewSupermemo2Plus() *Supermemo2Plus
NewSupermemo2Plus returns a new Supermemo2Plus instance
func (*Supermemo2Plus) Advance ¶
func (sm *Supermemo2Plus) Advance(rating float64) float64
Advance advances supermemo state for a card.
func (*Supermemo2Plus) Less ¶
func (sm *Supermemo2Plus) Less(other SRSAlgorithm) bool
Less defines card order for the review.
func (*Supermemo2Plus) MarshalJSON ¶
func (sm *Supermemo2Plus) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaller for Supermemo2Plus
func (*Supermemo2Plus) NextReviewAt ¶
func (sm *Supermemo2Plus) NextReviewAt() time.Time
NextReviewAt returns next review timestamp for a card.
func (*Supermemo2Plus) PercentOverdue ¶
func (sm *Supermemo2Plus) PercentOverdue() float64
PercentOverdue returns corresponding SM2+ value for a Card.
func (*Supermemo2Plus) UnmarshalJSON ¶
func (sm *Supermemo2Plus) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaller for Supermemo2Plus
type Supermemo2PlusCustom ¶
type Supermemo2PlusCustom struct {
Supermemo2Plus
}
Supermemo2PlusCustom calculates review intervals using altered SM2+ algorithm
func NewSupermemo2PlusCustom ¶
func NewSupermemo2PlusCustom() *Supermemo2PlusCustom
NewSupermemo2PlusCustom returns a new Supermemo2PlusCustom instance
func (*Supermemo2PlusCustom) Advance ¶
func (sm *Supermemo2PlusCustom) Advance(rating float64) float64
Advance advances supermemo state for a card.
func (*Supermemo2PlusCustom) Less ¶
func (sm *Supermemo2PlusCustom) Less(other SRSAlgorithm) bool
Less defines card order for the review.