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
- Host: GitHub
- URL: https://github.com/ix/ruffini
- Owner: ix
- License: mit
- Created: 2019-01-08T10:58:19.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-08T14:07:19.000Z (over 7 years ago)
- Last Synced: 2025-03-06T10:41:48.060Z (over 1 year ago)
- Language: Ruby
- Size: 3.91 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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!
```