Markov Polo
A No Bullshitâ„¢, Super-Tiny Markov Chain engine in Pure Ruby
Getting Started
Getting started is very simple. First, install the Gem:
gem install markov-polo
or, in your gem file
gem 'markov-polo'
Using the Gem is very simple. First, create a Chain
require 'markov-polo'
chain = MarkovPolo::Chain.new
To train your chain, it's just like with any Array.
chain << "These are some sample words"
chain.push "This is some more sample text"
Generating an output is also very simple
puts chain.generate # => These are some more sample words
Getting access to the raw chain data can be done by:
chain.to_h # => Hash
Restoring a chain from a hash can be done through the constructor
chain = MarkovPolo::Chain.new { ... }
Likewise, with the Hash, you can store your Chain as a JSON file, or other format of your choosing.
require 'json'
File.write "cache_chain.txt", JSON.generate(chain.to_h)