Method: Momblish#word
- Defined in:
- lib/momblish.rb
#word(length = nil) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/momblish.rb', line 59 def word(length = nil) length ||= rand(4..12) word = @corpus.weighted_bigrams.weighted_sample (length - 2).times do last_bigram = word[-2..-1] next_letter = @corpus.occurrences[last_bigram].weighted_sample return word.downcase if next_letter.nil? word += next_letter end word.downcase end |