diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-08-26 19:05:15 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-08-26 19:05:15 -0400 |
| commit | 5ec152ecd424d67474f36992acae5c620e46e2c6 (patch) | |
| tree | 2603fa1514ace8c75b8016e0da40398e71792c90 | |
| parent | f707a8510f52c1b9f4e0653d8f14c16a06492f40 (diff) | |
| download | markov-5ec152ecd424d67474f36992acae5c620e46e2c6.zip | |
update package comments
| -rw-r--r-- | fmt.go | 3 | ||||
| -rw-r--r-- | markov.go | 16 |
2 files changed, 12 insertions, 7 deletions
@@ -1,4 +1,5 @@ -// This program wraps its input into short lines. +// This program wraps its input into short lines. It is based on fmt.awk from +// "The Practice of Programming" by Brian Kernighan and Rob Pike (pp. 229). package main import ( @@ -1,6 +1,10 @@ -// This program implements a Markov chain algorithm. Given some input text, -// it generates pseudo-random phrases by repeatedly choosing a suffix word that -// follows the current multi-word prefix. +// This program implements a Markov chain algorithm. It generates pseudo-random +// prose based on the given input text. It works by breaking each phrase into two +// parts: a multi-word prefix, and a single suffix word. It generates output by randomly +// choosing a suffix that follows the prefix. +// +// The program is based on Chapter 3 of "The Practice of Programming" by +// Brian Kernighan and Rob Pike. package main import ( @@ -32,9 +36,9 @@ func (p *Prefix) push(word string) { } // StateMap associates each multi-word Prefix with a list of suffix words. -// The starting state is an empty Prefix{} with the suffix list containing -// the first word of the input text. The ending state is the last few words -// of the input text with an empty suffix list. +// The starting state is an empty Prefix{} with the suffix list containing the first word of +// the input text. The ending state is the last few words of the input text with an empty +// suffix list. type StateMap map[Prefix][]string func main() { |