Thanks to visit codestin.com
Credit goes to pkg.go.dev

fsrs

package module
v3.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2024 License: MIT Imports: 4 Imported by: 6

README

go-fsrs

Go Reference Go Report Card Go version

Go module implements Free Spaced Repetition Scheduler algorithm

Install

go get -u github.com/open-spaced-repetition/go-fsrs/v3@latest

Usage

Please see GoDoc and Wiki for documents.

Contributing

Please feel free to submit any Pull Requests. Just be sure not to introduce any breaking changes and do not any functionality excess the scope of the algorithm implementation.

For algorithm problems or discussions, please go open-spaced-repetition/free-spaced-repetition-scheduler.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FUZZ_RANGES = []FuzzRange{
	{Start: 2.5, End: 7.0, Factor: 0.15},
	{Start: 7.0, End: 20.0, Factor: 0.1},
	{Start: 20.0, End: math.Inf(1), Factor: 0.05},
}

Functions

func Mash added in v3.1.0

func Mash() func(string) float64

func NewAlea added in v3.1.0

func NewAlea(seed interface{}) *alea

Types

type Card

type Card struct {
	Due           time.Time `json:"Due"`
	Stability     float64   `json:"Stability"`
	Difficulty    float64   `json:"Difficulty"`
	ElapsedDays   uint64    `json:"ElapsedDays"`
	ScheduledDays uint64    `json:"ScheduledDays"`
	Reps          uint64    `json:"Reps"`
	Lapses        uint64    `json:"Lapses"`
	State         State     `json:"State"`
	LastReview    time.Time `json:"LastReview"`
}

func NewCard

func NewCard() Card

type FSRS

type FSRS struct {
	Parameters
}

func NewFSRS

func NewFSRS(param Parameters) *FSRS

func (*FSRS) GetRetrievability added in v3.2.0

func (f *FSRS) GetRetrievability(card Card, now time.Time) float64

func (*FSRS) Next

func (f *FSRS) Next(card Card, now time.Time, grade Rating) SchedulingInfo

func (*FSRS) Repeat

func (f *FSRS) Repeat(card Card, now time.Time) RecordLog

type FuzzRange added in v3.1.0

type FuzzRange struct {
	Start  float64
	End    float64
	Factor float64
}

type PRNG added in v3.1.0

type PRNG func() float64

func Alea added in v3.1.0

func Alea(seed interface{}) PRNG

func (PRNG) Double added in v3.1.0

func (prng PRNG) Double() float64

func (PRNG) ImportState added in v3.1.0

func (prng PRNG) ImportState(xg *alea, state state) PRNG

func (PRNG) Int32 added in v3.1.0

func (prng PRNG) Int32() int32

func (PRNG) State added in v3.1.0

func (prng PRNG) State(xg *alea) state

type Parameters

type Parameters struct {
	RequestRetention float64 `json:"RequestRetention"`
	MaximumInterval  float64 `json:"MaximumInterval"`
	W                Weights `json:"Weights"`
	Decay            float64 `json:"Decay"`
	Factor           float64 `json:"Factor"`
	EnableShortTerm  bool    `json:"EnableShortTerm"`
	EnableFuzz       bool    `json:"EnableFuzz"`
	// contains filtered or unexported fields
}

func DefaultParam

func DefaultParam() Parameters

func (*Parameters) ApplyFuzz added in v3.1.0

func (p *Parameters) ApplyFuzz(ivl float64, elapsedDays float64, enableFuzz bool) float64

func (*Parameters) NewBasicScheduler

func (p *Parameters) NewBasicScheduler(card Card, now time.Time) *Scheduler

func (*Parameters) NewLongTermScheduler

func (p *Parameters) NewLongTermScheduler(card Card, now time.Time) *Scheduler

type Rating

type Rating int8
const (
	Again Rating = iota + 1
	Hard
	Good
	Easy
)

func (Rating) String

func (s Rating) String() string

type RecordLog

type RecordLog map[Rating]SchedulingInfo

type ReviewLog

type ReviewLog struct {
	Rating        Rating    `json:"Rating"`
	ScheduledDays uint64    `json:"ScheduledDays"`
	ElapsedDays   uint64    `json:"ElapsedDays"`
	Review        time.Time `json:"Review"`
	State         State     `json:"State"`
}

type Scheduler

type Scheduler struct {
	// contains filtered or unexported fields
}

func (*Scheduler) Preview

func (s *Scheduler) Preview() RecordLog

func (*Scheduler) Review

func (s *Scheduler) Review(grade Rating) SchedulingInfo

type SchedulingInfo

type SchedulingInfo struct {
	Card      Card
	ReviewLog ReviewLog
}

type State

type State int8
const (
	New State = iota
	Learning
	Review
	Relearning
)

type Weights

type Weights [19]float64

func DefaultWeights

func DefaultWeights() Weights

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL