Markov Chain

DESCRIPTION

A simple library for creating Markov chains from strings of text.

SYNOPSIS

require 'markov_chain'

# Generate a chain and return the results
MarkovChain.grow_string 'foo' # ["foo", "foon", "foone", "foona", "foong", "foonan", "foones" ...

# Explicitly load the default dictionary
MarkovChain.load_dictionary!

# Load a custom dictionary
MarkovChain.load_dictionary! '/path/to/dictionary'

# Check if a dictionary is loaded
MarkovChain.dictionary_loaded?

# Check the path of the loaded dictionary
MarkovChain.dictionary # '/path/to/dictionary'

# Specify the max number of words returned and the size of those words
MarkovChain.grow_string('foo', :max_size => 6, :max_word_length => 4) # ["foo", "foon", "foong", "foone", "foona", "foongl"]

LIMITATIONS

This library currently only supports the extension of words, character by character. In the future, it ought to be able to build a Markov Chain using any kind of input array.

INSTALL:

gem install markov_chain

LICENSE:

(The MIT License)

Copyright © 2011 Alex Rabarts

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.