Categorygithub.com/ap4y/leaf
modulepackage
0.0.0-20200617025226-f32db495286d
Repository: https://github.com/ap4y/leaf.git
Documentation: pkg.go.dev

# README

  • Leaf

Leaf is a flashcard app that uses [[https://en.wikipedia.org/wiki/Spaced_repetition][spaced repetition]] algorithm. Leaf focuses on simplifying database management, ease of access and support for various spaced repetition curves (including custom).

[[https://gitlab.com/ap4y/leaf/raw/master/screenshot.png]]

** Getting started

Leaf is a [[https://golang.org/][golang]] application and you are going to need golang toolchain to compile the app.

To install or update run:

#+BEGIN_SRC shell go get -u github.com/ap4y/leaf/cmd/leaf #+END_SRC

or

#+BEGIN_SRC shell go get -u github.com/ap4y/leaf/cmd/leaf-server #+END_SRC

Leaf provides 2 different versions:

  • leaf is a command line utility that provides review UI in the terminal
  • leaf-server is a web app that implements review UI along with additional features like stats viewer.

Both utilities have following configuration options:

  • -decks . is a path to a folder with deck files.
  • -db leaf.db is a location of a stats DB that contains spaced repetition variables for your decks.

For leaf-server you can also adjust address to start server on via -addr :8000.

Terminal CLI (leaf) has following commands:

  • review will initiate review session for a deck
  • stats will return stats snapshots for a deck

Both commands expect deck name after the command name. Full example:

#+BEGIN_SRC shell ./leaf -decks ./fixtures review Hiragana #+END_SRC

** Database management

Leaf uses plain text files structured usin [[https://orgmode.org/manual/Headlines.html#Headlines][org-mode headlines]]. Consider following file:

#+BEGIN_SRC org

  • Sample :PROPERTIES: :RATER: auto :ALGORITHM: sm2+c :PER_REVIEW: 20 :SIDES: answer :END: ** Question 1 Answer 1 ** Question 2 Answer 2 #+END_SRC

Such file will be parsed as a deck named Sample and it will have 2 cards. For a full deck example check [[https://gitlab.com/ap4y/leaf/raw/master/fixtures/hiragana.org][hiragana]] deck.

You can use text formatting, images, links and code blocks in your deck files. Check [[https://gitlab.com/ap4y/leaf/raw/master/fixtures/org-mode.org][org-mode]] deck for an overview of supported options.

Top header level property drawer is used to adjust review parameters. Following parameters are supported:

  • ALGORITHM is a spaced repetition algorithm to use. Default is sm2+c. All possible values can be found [[https://gitlab.com/ap4y/leaf/blob/master/stats.go#L35-44][here]].
  • RATER defines which rating system will be used for reviews. Defaults to auto, supported values: auto and self.
  • PER_REVIEW is a maximum amount of cards per review session.
  • SIDES is an optional field that defines names of the card sides, used in the UI for placeholders.

Spaced repetition variables are stored in a separate file in a binary database. You can edit deck files at any time and changes will be automatically reflected in the web app.

** Spaced repetition algorithms

Leaf implements multiple spaced repetition algorithms and allows you to define new ones. Following algorithms are supported as of now:

You can find calculated intervals in corresponding test files. Check [[https://gitlab.com/ap4y/leaf/blob/master/stats.go#L9-19][SRSAlgorithm]] interface to define a new algorithm or curve.

Please keep in mind that algorithm variables may not be compatible with each other and algorithm switching is not supported.

** Review rating

All reviews are rated using [0..1] scale. Rating higher than 0.6 will mark review as successful. You can use 2 different types of rating systems:

To change rating system for a deck define org-mode property RATER in your deck file.

# Packages

No description provided by the author
No description provided by the author

# Functions

HarshRater returns miss count based Rater.
NewDeckManager constructs a new DeckManager by reading all decks from a given folder using provided store.
NewEbisu consturcts a new Ebisu instance.
NewReviewSession constructs a new ReviewSession for a given set of cards.
NewStats returns a new Stats initialized with provided algorithm with default values.
NewSupermemo2 returns a new Supermemo2 instance.
NewSupermemo2Plus returns a new Supermemo2Plus instance.
NewSupermemo2PlusCustom returns a new Supermemo2PlusCustom instance.
OpenBoltStore returns a new StatsStore implemented on top of BoltDB.
OpenDeck loads deck from an org file.
TableRater returns Rater implementation with following the conversion table: again => 0 hard => 0.2 good => 0.6 easy => 1.0.

# Constants

DeckPropertyAlgorithm defines deck's org-mode property for the algorithm.
DeckPropertyPerReview defines deck's org-mode property for the per review amount.
DeckPropertyRater defines deck's org-mode property for the rater.
DeckPropertySides defines deck's org-mode property for the side names.
OutputFormatHTML defines html output.
OutputFormatOrg defines pretty printed org output.
RatingTypeAuto defines auto rated review option.
RatingTypeSelf defines self rated review option.
ReviewScoreAgain defines "again" score.
ReviewScoreEasy defines "easy" score.
ReviewScoreGood defines "good" score.
ReviewScoreHard defines "hard" score.
SRSEbisu represents Ebisu algorithm.
SRSSupermemo2 represents Supermemo2 algorithm.
SRSSupermemo2Plus represents Supermemo2Plus algorithm.
SRSSupermemo2PlusCustom represents Supermemo2PlusCustom algorithm.

# Variables

ErrNotFound represents error returned for requests for non-existing deck.

# Structs

Card represents a single card in a Deck.
CardWithStats joins Stats to a Card.
Deck represents a named collection of the cards to review.
DeckManager manages set of decks.
DeckStats stores overview stats for a Deck.
Ebisu implements ebisu SSR algorithm.
IntervalSnapshot records historical changes of the Interval.
ReviewSession contains parameters for a Deck review sessions.
Stats store SM2+ parameters for a Card.
Supermemo2 calculates review intervals using SM2 algorithm.
Supermemo2Plus calculates review intervals using SM2+ algorithm.
Supermemo2PlusCustom calculates review intervals using altered SM2+ algorithm.

# Interfaces

Rater rates review attempt based on amount of mistakes.
SRSAlgorithm calculates review intervals.
StatsStore defines storage interface that is used for storing review stats.

# Type aliases

OutputFormat defines output type produces during org file parsing.
RatingType defines types of review rating options.
ReviewScore defines grade for review attempts.
SRS defines supported spaced-repetiton algorithms.
StatsSaveFunc persists stats updates.