3 # Author: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
4 # New markov chain plugin tester
8 fname = ARGV.fetch(0, "promessi.txt")
10 max_ord = ARGV.fetch(1, 5).to_i
12 min_ord = ARGV.fetch(2, 5).to_i
14 mkv = MarkovChainer.new(max_ord)
16 size = File.size?(fname)
21 File.open(fname) { |file|
24 new_ratio = file.pos*100/size
25 if new_ratio > old_ratio
27 puts "\n\n\nLearned #{new_ratio}%"
28 puts "%u words known" % mkv.words.length
29 min_ord.upto(max_ord) { |ord|
30 puts "\nOrder #{ord}::"
31 puts mkv.complete("", :max_order=>ord)