Sha256: 6467de115ccab86d2e95b839b24314760539dae7d4ee489f8aa961444a7866e0
Contents?: true
Size: 748 Bytes
Versions: 1
Compression:
Stored size: 748 Bytes
Contents
module MarkovUuid class Markov include KeySelector SEPARATOR = "#-#-" def to_s i=8 @words.join("")[0..i.to_i] end def initialize words @words = words end def add_to markov_data key = SEPARATOR @words.each do |word| (markov_data[key] ||= []) << word key = new_key(key, word) end end private class << self def from_file( f ) new lines(f).map { |l| from_string l }.flatten end private def from_string l l.gsub(/[^a-z]/i,'').split // end def lines f content = File.read f c = content.length r = rand c content[r-c .. r+c].downcase.split "\n" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
markov_uuid-0.0.1 | lib/markov_uuid/markov.rb |