Description
A Markov chain algorithm optimized by memory consumption generates text by creating a statistical model of potential textual Suffixes for a given Links.
Generating random text: a Markov chain algorithm
A Markov chain algorithm generates text by creating a statistical model of potential textual suffixes for a given links of chain.
Markov Chain Algorithm alternatives and similar packages
Based on the "Text Processing" category.
Alternatively, view Markov Chain Algorithm alternatives based on common mentions on social networks and blogs.

goldmark
:trophy: A markdown parser written in Go. Easy to extend, standard(CommonMark) compliant, well structured. 
bluemonday
bluemonday: a fast golang HTML sanitizer (inspired by the OWASP Java HTML Sanitizer) to scrub user generated content of XSS 
omniparser
omniparser: a native Golang ETL streaming parser and transform library for CSV, JSON, XML, EDI, text, etc. 
htmltomarkdown
โ๏ธ Convert HTML to Markdown. Even works with entire websites and can be extended through rules. 
mxj
Decode / encode XML to/from map[string]interface{} (or JSON); extract values with dotnotation paths and wildcards. Replaces x2j and j2x packages. 
gopkgrss
DISCONTINUED. This package reads RSS and Atom feeds and provides a caching mechanism that adheres to the feed specs. 
goedlib
๐ String comparison and edit distance algorithms library, featuring : Levenshtein, LCS, Hamming, Damerau levenshtein (OSA and Adjacent transpositions algorithms), JaroWinkler, Cosine, etc... 
goq
A declarative structtagbased HTML unmarshaling or scraping package for Go built on top of the goquery library 
github_flavored_markdown
GitHub Flavored Markdown renderer with fenced code block highlighting, clickable header anchor links. 
gopkgxmlx
DISCONTINUED. Extension to the standard Go XML package. Maintains a node tree that allows forward/backwards browsing and exposes some simple single/multinode search functions. 
pagser
Pagser is a simple, extensible, configurable parse and deserialize html page to struct based on goquery and struct tags for golang crawler
CodeRabbit: AI Code Reviews for Developers
Do you think we are missing an alternative of Markov Chain Algorithm or a related project?
README
Markov Chain Algorithm
A Markov chain algorithm optimized by memory consumption generates text by creating a statistical model of potential textual Suffixes for a given Links.
Generating random text: a Markov chain algorithm
Based on the program presented in the "Design and Implementation" chapter of The Practice of Programming (Kernighan and Pike, AddisonWesley 1999). See also Computer Recreations, Scientific American 260, 122  125 (1989).
A Markov chain algorithm generates text by creating a statistical model of potential textual suffixes for a given links of chain. Consider this text:
One fish one fish one fish two fish red fish blue fish
Our Markov chain algorithm would arrange this text into this set of links and suffixes, or "chain": (This table assumes a link length of two words.)
Link Suffix
======== ==================
"" "" [One, 1]
"" One [fish, 3]
One fish [One, 2], [two, 1]
fish one [fish,2]
fish two [fish,1]
Two fish [red,1]
fish red [fish, 1]
red fish [blue, 1]
blue fish [`END`, 1]
To generate text using this table we select an initial links ("One fish", for example), choose one of the suffixes associated with that prefix at random with probability determined by the input statistics ("One, 2", "fish, 1"), and then create a new links by removing the first word from the link and appending the suffix (making the new link is "fish one" and second "fish two"). Repeat this process until we can't find any suffixes for the current link or we exceed the word limit. (The word limit is necessary as the chain table may contain cycles.)
Current optimized algorithm support similar logic described at following example: https://golang.org/doc/codewalk/markov/, but optimized for memory consumption when base text contains lot of identical suffixes for the same link. E.g. in example above following pair of link and suffexes below would contain 2 same suffixes for "one" and 1 for "fish"
Link Suffix
======== ==================
... ...
One fish one, one, fish
but in optimized version pairs of link and related suffixes would be created in the following way when each suffix contains number of appearances with the appropriate link.
Link Suffix
======== ==================
... ...
One fish [One, 2], [two, 1]
Note: keep in mind if your text not long or you're suggesting it is not contains lot of duplicated pair of link and suffixes initial version of algorithm might be more optimized from performance prospectives.
Enjoy coding!!
Example
c := NewChain(2) // Words per Links
c.Build(strings.NewReader("One fish two fish red fish blue fish))"
text := c.Generate(250) // Generate text.
fmt.Println(text)
Contributing
We welcome pull requests, bug fixes and issue reports.
Before proposing a change, please discuss your change by raising an issue.
Authors
 Valentyn Ponomarenko  Initial work  PARUS
License
This project is licensed under the MIT License  see the [LICENSE.md](LICENSE.md) file for details
*Note that all licence references and agreements mentioned in the Markov Chain Algorithm README section above
are relevant to that project's source code only.