store

package
v0.0.0-...-c6bdbe1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StripColors

func StripColors(s string) string

StripColors cleans any color related unprintable symbols

Types

type CSV

type CSV struct {
	Path string
}

CSV is .csv store backend for words. Compliantly simple. Read full file from disk. Save method will override whole file.

func NewCSV

func NewCSV(path string) (*CSV, error)

NewCSV open creates new CSV store. Creates a new CSV file, if it does not exist.

func (CSV) AddWord

func (c CSV) AddWord(w *Word) error

AddWord adds new word in words collection and saves on disc

func (CSV) GetWords

func (c CSV) GetWords(n int) (*Words, error)

GetWords loads words and put in into a heap according the score

func (CSV) Save

func (c CSV) Save(w *Word) error

Save saves Word into CSV file

type Word

type Word struct {
	Origin, Translation, Meta string
	LastSeenAt                time.Time
	Score                     int
}

Word is word for learning with all required metadata.

func NewWord

func NewWord(raw string) *Word

NewWord create a new Word instance, including try to get word metadata form VerbFormen.

func (*Word) DecScore

func (w *Word) DecScore()

DecScore decrease particular Word score

func (*Word) GetMeta

func (w *Word) GetMeta() string

GetMeta returns formatted Meta

func (*Word) GetMetaWithoutColors

func (w *Word) GetMetaWithoutColors() string

GetMetaWithoutColors return pure string without ASCII colors

func (*Word) HasMeta

func (w *Word) HasMeta() bool

HasMeta indicate if Word has Meta data

func (*Word) IncScore

func (w *Word) IncScore()

IncScore increases particular Word score

func (Word) String

func (w Word) String() string

type Words

type Words []*Word

Words is a heap of Word's

func (*Words) IsEmpty

func (ws *Words) IsEmpty() bool

IsEmpty returns false if heap is empty

func (*Words) Len

func (ws *Words) Len() int

Len Less Swap Push Pop needs to implement heap interface

func (*Words) Less

func (ws *Words) Less(i, j int) bool

func (*Words) Next

func (ws *Words) Next() (w *Word)

Next pops and returns next word

func (*Words) Pop

func (ws *Words) Pop() any

Pop remove last word from heap and returns it

func (*Words) Push

func (ws *Words) Push(x any)

Push adds Word into heap

func (*Words) String

func (ws *Words) String() string

func (*Words) Swap

func (ws *Words) Swap(i, j int)

Jump to

Keyboard shortcuts

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