Skip to content

zgiber/mctext

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

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:

...
  mc := mctext.New()
  mc.Parse(Sample) // The default sample is Tom Sawyer from Mark Twain :)
...

About

Random-text generator using Markov chain from user-provided sample.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages