https://github.com/zgiber/mctext
Random-text generator using Markov chain from user-provided sample.
https://github.com/zgiber/mctext
Last synced: about 1 year ago
JSON representation
Random-text generator using Markov chain from user-provided sample.
- Host: GitHub
- URL: https://github.com/zgiber/mctext
- Owner: zgiber
- License: mit
- Created: 2016-12-13T10:13:41.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-12-21T23:10:03.000Z (over 8 years ago)
- Last Synced: 2025-02-04T16:23:24.920Z (over 1 year ago)
- Language: Go
- Size: 715 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mctext
Random-text generator using Markov chain from an user-provided sample. It's useful in cases where generated text must be relatively random,
but expected to contain a good average distribution and repetition of words.
Example:
```go
import "github.com/zgiber/mctext"
...
// provide an io.Reader with the sample. Ideally UTF encoded text.
// ...
var r io.Reader
...
mc := mctext.New()
mc.Parse(r)
output := mc.Generate("",100) // Generate text with 100 words without defining any starting word.
```
If you don't want to provide your own io.Reader you can use the sample in the library:
```go
...
mc := mctext.New()
mc.Parse(Sample) // The default sample is Tom Sawyer from Mark Twain :)
...
```