flashcards

package module
v0.0.0-...-5d63be7 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2018 License: MIT Imports: 15 Imported by: 0

README

Flashcards

MIT license Go Report Card Codacy Badge Build Status codecov

Simulate a set of flashcards to help learn a new language

Automatically adjusts cards returns to factor in what you've previously learned i.e. focus on what you don't know rather than on what you've already learned

For now just terminal based so something a little bit like

10
Translate: кукуруза  kukuruza
    1) birthday
    2) baby
    3) corn
    4) snow
Type your answer: corn
Correct!


11
Translate: пол  pol
    1) floor
    2) ring
    3) party
    4) flower
Type your answer: floor
Correct!


12
Translate: земля  zemlya
    1) ground
    2) hand
    3) letter
    4) doll
Type your answer: hand
ERRO[0037] Incorrect!!   земля  zemlya    ground

Updates to come that

  • add ability to render actual pictures as flashcards
  • expand phrase set and translations
  • auto translations
  • groups of nouns/verbs etc.
  • adding better cmd args

Documentation

Index

Constants

View Source
const (
	English = Language("English")
	Russian = Language("Russian")
	French  = Language("French")
)

Languages supported

View Source
const DefaultDeckName = "flashcardsDeck.db"

DefaultDeckName is the default deck db

Variables

This section is empty.

Functions

func ShuffleCards

func ShuffleCards(cards []*Card)

ShuffleCards reorders items in the slice of cards using a PRNG

Types

type Card

type Card struct {
	ID     ID      `json:"-"`
	Phrase *Phrase `json:"phrase,omitempty"`
}

Card is a single card in the deck

func NewCard

func NewCard(p *Phrase) *Card

NewCard generates a new card to represdent a single phrase

func (*Card) AttemptAnswer

func (c *Card) AttemptAnswer(know, learning Language, attempt string)

AttemptAnswer accepts an answer from a user and checks whether it is correct

func (*Card) PrintQuestion

func (c *Card) PrintQuestion(deck *Deck) string

PrintQuestion is a pretty formatter for command line version of rendering the card

type Deck

type Deck struct {
	ID       ID       `json:"-"`
	Last     *Card    `json:"-"`
	Current  *Card    `json:"-"`
	Know     Language `json:"know,omitempty"`
	Learning Language `json:"learning,omitempty"`

	Cards []*Card `json:"cards,omitempty"`
	// contains filtered or unexported fields
}

Deck is a parennt for a group of cards

func NewDeck

func NewDeck(path string) *Deck

NewDeck generates a deck with all known phrases

func NewDeckWithSize

func NewDeckWithSize(path string, start, end int, shuffle bool) *Deck

NewDeckWithSize extracts a subset of NewDeck

func NewStandardDeck

func NewStandardDeck() *Deck

NewStandardDeck returns a deck with sensible defaults

func (*Deck) GetIncorrectGuesses

func (d *Deck) GetIncorrectGuesses(correct *Card, n int) []*Card

GetIncorrectGuesses gets a set of incorrect answers

func (*Deck) Next

func (d *Deck) Next() *Card

Next takes the first card from the deck

func (*Deck) SaveState

func (d *Deck) SaveState()

SaveState saves the current state of the deck

func (*Deck) Shuffle

func (d *Deck) Shuffle()

Shuffle reorders all cards in the deck

func (*Deck) WithCard

func (d *Deck) WithCard(c *Card) *Deck

WithCard adds a new card to the deck

type ID

type ID string

ID is unique identifier

func NewID

func NewID() ID

NewID generates a new unique identifer

func (*ID) String

func (id *ID) String() string

String is a string representation of the ID

type Language

type Language string

Language is a as it says on the tin :)

type Phonetic

type Phonetic struct {
	ID       ID `json:"-"`
	Language `json:"language,omitempty"`
	Value    string `json:"value,omitempty"`
}

Phonetic is a helper on how to pronounce a phrase

func NewPhonetic

func NewPhonetic(l Language, value string) *Phonetic

NewPhonetic craetes a new Phonetic

type Phrase

type Phrase struct {
	ID           ID             `json:"-"`
	Translations []*Translation `json:"translations,omitempty"`
}

Phrase is a phrase from a languages that contains some translations in different languages

func NewPhrase

func NewPhrase() *Phrase

NewPhrase generates a new phrase

func (*Phrase) Language

func (p *Phrase) Language(l Language) *Translation

Language gets the translation for the phrase in said language

func (*Phrase) WithTranslation

func (p *Phrase) WithTranslation(t *Translation) *Phrase

WithTranslation adds a translation for a phrase

type Stats

type Stats struct {
	ID         ID      `json:"-"`
	Attempts   int     `json:"attempts"`
	Correct    int     `json:"correct"`
	Percentage float64 `json:"percentage"`
	Weighting  float64 `json:"weighting"`
}

Stats contains info on how player is learning a specific phrase

func NewStats

func NewStats() *Stats

NewStats returns a new stats

func (*Stats) CorrectAttempt

func (s *Stats) CorrectAttempt()

CorrectAttempt records a correct attempt

func (*Stats) String

func (s *Stats) String() string

String returns a formatte representation of stats

func (*Stats) WrongAttempt

func (s *Stats) WrongAttempt()

WrongAttempt records an incorrect attempt

type Translation

type Translation struct {
	ID        ID `json:"-"`
	Language  `json:"language,omitempty"`
	Value     string      `json:"value,omitempty"`
	Phonetics []*Phonetic `json:"phonetics,omitempty"`
	Stats     *Stats      `json:"stats,omitempty"`
}

Translation represents how a specific phrase is representated in a given language

func NewTranslation

func NewTranslation(l Language, value string) *Translation

NewTranslation generates a new translation

func (*Translation) GetPhonetic

func (t *Translation) GetPhonetic(l Language) *Phonetic

GetPhonetic gets the phonetic for a given lanuage

func (*Translation) WithPhonetic

func (t *Translation) WithPhonetic(p *Phonetic) *Translation

WithPhonetic adds a phonetic for a translation

Directories

Path Synopsis
cmd
api

Jump to

Keyboard shortcuts

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