markov

package
v0.0.0-...-6ebd40e Latest Latest
Warning

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

Go to latest
Published: May 25, 2017 License: GPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildChain

func BuildChain(songs []lastFm.Song) map[string]Suffixes

BuildChain determines what songs are played after others and creates a chain to then randomly select from. Takes an array of songs and returns a map.

func GenerateSongList

func GenerateSongList(length int, maxBySameArtist int, startingSong lastFm.Song, chain map[string]Suffixes) ([]lastFm.Song, error)

GenerateSongList takes a seed song, a chain to select from, a length, and the maximum songs by one artist in a row. It returns a list of songs and an optional error.

Types

type CDF

type CDF [][2]int

CDF is a structure for a continuous distribution function, generated from the chain.

func (CDF) Len

func (cdf CDF) Len() int

Sort interface implementation

func (CDF) Less

func (cdf CDF) Less(i, j int) bool

func (CDF) Swap

func (cdf CDF) Swap(i, j int)

type Suffix

type Suffix struct {
	Name      string
	Artist    string // for more accurate lookup in Spotify
	Frequency int    // number of times the suffix happens
}

Suffix holds a song that occurs after another song. Multiple suffixes with the same name can be duplicated across multiple source songs.

type Suffixes

type Suffixes struct {
	Suffixes []Suffix
	Total    int // total number of Frequencies
}

Suffixes holds all suffixes for a specific song

Jump to

Keyboard shortcuts

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