aboutsummaryrefslogtreecommitdiff
path: root/markov-serialise.rb
diff options
context:
space:
mode:
authorNathan Lasseter <nathan@4574.co.uk>2014-01-19 12:05:49 +0000
committerNathan Lasseter <nathan@4574.co.uk>2014-01-19 12:05:49 +0000
commitf091c51626c1ef62c9e81e0b1207b46a0666f5bf (patch)
tree66cc85d93e1cdbca28481d3a3f3b2b8d9d845857 /markov-serialise.rb
parent7cbacfed6ea9ce55b1db181550f826a8ec085dfe (diff)
Changed the serialisation to use single word follow-ons. Added the number of generations argument to markov-run. Changed the length argument from number of achunks to the total words in the generation. Removed the "Starts with a capital" requirement.
Diffstat (limited to 'markov-serialise.rb')
-rwxr-xr-xmarkov-serialise.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/markov-serialise.rb b/markov-serialise.rb
index 00e459e..1199453 100755
--- a/markov-serialise.rb
+++ b/markov-serialise.rb
@@ -2,7 +2,7 @@
CHUNK = ARGV[1].to_i
-stats = Hash.new
+stats = {"__SETTINGS__" => {"__CHUNK__" => CHUNK}}
words = File.readlines(ARGV[0])
.map(&:split)
@@ -10,7 +10,7 @@ words = File.readlines(ARGV[0])
(0 .. (words.length - CHUNK - CHUNK)).each do |i|
k = words[i...(i+CHUNK)]
- v = words[(i+CHUNK)...(i+CHUNK+CHUNK)]
+ v = words[(i+CHUNK)]
if stats.include?(k) then
t = stats[k]
if t.include?(v) then