markov_chain 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +11 -0
- data/Gemfile.lock +18 -0
- data/History.txt +3 -0
- data/README.rdoc +27 -0
- data/Rakefile +26 -0
- data/VERSION +1 -0
- data/lib/dictionaries/american_english +98569 -0
- data/lib/markov_chain.rb +124 -0
- data/test/markov_chain_test.rb +13 -0
- data/test/test_helper.rb +9 -0
- metadata +103 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/History.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
= Markov Chain
|
2
|
+
|
3
|
+
== DESCRIPTION
|
4
|
+
|
5
|
+
A simple library for creating Markov chains from strings of text.
|
6
|
+
|
7
|
+
== SYNOPSIS
|
8
|
+
|
9
|
+
require 'markov_chain'
|
10
|
+
|
11
|
+
# Generate a chain and return the results
|
12
|
+
MarkovChain.generate 'foo' # ["foo", "foon", "foone", "foona", "foong", "foonan", "foones" ...
|
13
|
+
|
14
|
+
# Explicitly load the default dictionary
|
15
|
+
MarkovChain.load_dictionary!
|
16
|
+
|
17
|
+
# Load a custom dictionary
|
18
|
+
MarkovChain.load_dictionary! '/path/to/dictionary'
|
19
|
+
|
20
|
+
# Check if a dictionary is loaded
|
21
|
+
MarkovChain.dictionary_loaded?
|
22
|
+
|
23
|
+
# Check the path of the loaded dictionary
|
24
|
+
MarkovChain.dictionary # '/path/to/dictionary'
|
25
|
+
|
26
|
+
# Specify the max number of words returned and the size of those words
|
27
|
+
MarkovChain.generate('foo', :max_size => 6, :max_word_length => 4) # ["foo", "foon", "foong", "foone", "foona", "foongl"]
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'jeweler'
|
5
|
+
Jeweler::Tasks.new do |s|
|
6
|
+
s.name = 'markov_chain'
|
7
|
+
s.summary = %Q{
|
8
|
+
A simple Markov chain generator.
|
9
|
+
}
|
10
|
+
s.email = 'alexrabarts@gmail.com'
|
11
|
+
s.homepage = 'http://github.com/alexrabarts/markov_chain'
|
12
|
+
s.description = 'Markov chain generator'
|
13
|
+
s.authors = ['Alex Rabarts']
|
14
|
+
end
|
15
|
+
rescue LoadError
|
16
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'rake/testtask'
|
20
|
+
Rake::TestTask.new(:test) do |t|
|
21
|
+
t.libs << 'lib' << 'test'
|
22
|
+
t.pattern = 'test/**/*_test.rb'
|
23
|
+
t.verbose = false
|
24
|
+
end
|
25
|
+
|
26
|
+
task :default => :test
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|