An open API service indexing awesome lists of open source software.

https://github.com/ix/ruffini

a markov library for ruby which emphasizes minimalism and a heightened degree of control
https://github.com/ix/ruffini

Last synced: about 1 year ago
JSON representation

a markov library for ruby which emphasizes minimalism and a heightened degree of control

Awesome Lists containing this project

README

          

Ruffini
=======

Ruffini is a markov text library that is small, straightforward
and allows you to do things like set the dictionary entry from
which new text will be generated.

Check out this usage example:

```ruby
require 'ruffini'

EXAMPLE = <<~TEXT
I like apples and strawberries.
I like cheese and ham.
I like tea and coffee.
I like sunsets and rainy days.
TEXT

# first parameter denotes the 'depth' of the database
database = Ruffini::Markov.new(1)

database.parse! EXAMPLE

# generate up to 10 words at random
puts database.generate(10)

# provide an initial string to start generating from!
puts database.generate(10, "I")

# we could save the database for later use!
# database.save! "my_database.markov"

# then load it like this
# database = Ruffini::Markov.new(1, "my_database.markov")
# depth must remain the same!
```