Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MarkovChain ¶
type MarkovChain interface { AddStringToData(string) error ReadInTextFile(string) error GenerateSentence(int) (string, error) SaveToFile(string) error }
func ReadinFile ¶
func ReadinFile(filepath string) (MarkovChain, error)
ReadinFile loads a previously saved database file, deserializes it, and returns a struct matching the MarkovChain interface
type MarkovData ¶
type MarkovData struct { StartWords []uint `json:"StartWords"` // Numeric references to each start word WordCount uint `json:"WordCount"` // Number of words available WordRef map[string]uint `json:"WordMap"` // Word to number mappings WordVals []string `json:"WordVals"` // Number to word mappings WordGraph []map[uint]uint `json:"WordGraph"` // Mappings of word number -> word number with frequency of relationship // contains filtered or unexported fields }
func (*MarkovData) AddStringToData ¶
func (md *MarkovData) AddStringToData(input string) error
AddStringToData gets a string and parses it into a format that is interpretable by the MarkovData struct
func (*MarkovData) GenerateSentence ¶
func (md *MarkovData) GenerateSentence(limit int) (string, error)
GenerateSentence produces a sentence using the provided database
func (*MarkovData) ReadInTextFile ¶
func (md *MarkovData) ReadInTextFile(filename string) error
ReadInTextFile reads in an entire text file and adds to the Markov Chain database
func (*MarkovData) SaveToFile ¶
func (md *MarkovData) SaveToFile(filename string) error
SaveToFile outputs the data generated to a file, since it's not exactly human readable, it's just clumped together
type MarkovDataOld ¶
type MarkovDataOld struct { Startwords []string `json:"Startwords"` Wordmaps map[string]map[string]int `json:"Wordmaps"` // contains filtered or unexported fields }
func (*MarkovDataOld) AddStringToData ¶
func (md *MarkovDataOld) AddStringToData(input string) error
AddStringToData parses a string and inserts it in the MarkovData struct as appropriate
func (*MarkovDataOld) GenerateSentence ¶
func (md *MarkovDataOld) GenerateSentence(limit int) (string, error)
GenerateSentence creates a sentence using the input data
func (*MarkovDataOld) ReadInTextFile ¶
func (md *MarkovDataOld) ReadInTextFile(filename string) error
ReadInTextFile reads in an entire text file and adds to the Markov Chain database
func (*MarkovDataOld) SaveToFile ¶
func (md *MarkovDataOld) SaveToFile(filename string) error
SaveToFile exports the current MarkovData struct to a file of choice Pass an empty string to save the data to a file called output.json in the current directory