Home
Softono

Go Srs

Open source MIT Go
14
Stars
0
Forks
1
Issues
1
Watchers
1 year
Last Commit

 About Go Srs

Go implementation of the sm2 (SuperMemo) algorithm

Platforms

Web Self-hosted

Languages

Go

Need Help Installing Go Srs?

We provide expert installation service for this software. Our team will install, configure, and secure Go Srs on your server. plans start at just $30.

go-srs

Go Reference Test Go Report Card GitHub Release GitHub Release GitHub stars sloc

go-srs: Empowering spaced repetition learning in Go

go-srs offers a comprehensive Go implementation of the SuperMemo 2 (sm2) algorithm, along with libraries designed to facilitate the creation of spaced repetition learning-capable programs and servers.

Key Features

  • SuperMemo 2 (sm2) Algorithm Implementation: go-srs includes a robust implementation of the SuperMemo 2 (sm2) algorithm.

  • Local Database Client: Leveraging badger, go-srs comes equipped with a local database client.

  • Unique ID Generator: The library features a unique ID generator based on ulid.

Use

First, instantiate the srs struct with the provided algorithm, uid and db implementations:

// Algo
now := time.Now().UTC()
sm2 := sm2.New(now)

// Db
opts := badger.DefaultOptions("./badger")
opts.Logger = nil
bad, err := badger.Open(opts)
defer bad.Close()
db := bdg.New(bad, sm2)

// uid
entropy := ulidPkg.Monotonic(crand.Reader, 0)
uid := ulid.New(entropy)

// instantiate srs struct
hdl := srs.New(db, uid)

After that, you can update and save card reviews of a given deck:

r = review.Review{}
r.DeckId = "somedeckid"

r.Items = []review.ReviewItem{
    {CardId: 65, Quality: 1},
    {CardId: 3, Quality: 5},
    {CardId: 1, Quality: 0},
}

_, err = hdl.Update(r)
if err != nil {
    fatal(err)
}

And retrieve cards that are due for review

tdue := time.Now().UTC()
dueCards, _ := hdl.Due(res.DeckId, tdue)

See srs_test.go for more examples.

Additional implementations

go-srs provides interfaces for db, algorithm and unique id implementations.