module Markov::Util
Public Instance Methods
random_number(upper_limit)
click to toggle source
# File lib/markov/util.rb, line 40 def random_number(upper_limit) (SecureRandom.random_number * upper_limit).to_i end
tokens_to_debug(tokens)
click to toggle source
# File lib/markov/util.rb, line 27 def tokens_to_debug(tokens) s = "" tokens.each do |t| if t.kind != :word s << " " + t.to_symbol else s << " " + t.word end end s[1, s.length-1] end
tokens_to_sentence(tokens)
click to toggle source
# File lib/markov/util.rb, line 14 def tokens_to_sentence(tokens) s = "" tokens.each do |t| if t.kind != :word s << t.word else s << " " + t.word end end s[1, s.length-1] end
tokens_to_words(tokens)
click to toggle source
# File lib/markov/util.rb, line 6 def tokens_to_words(tokens) words = [] tokens.each do |t| words << t.word end words end