lib/two_chainz/generator.rb
# Internal: Get a word that comes after the specified one.
#
# previous_word - The word that will be coming before whichever one we pick.
#
# Returns a string.
Get a word that comes after the specified one.
previous_word - The word that will be coming before whichever one we pick.

Returns a string.
Get a word that comes after the specified one . previous_word - The word that will be coming before whichever one we pick . Returns a string .
def word_after(previous_word)
    next_word = nil
    choices   = @words_table.words_after(previous_word)
    if @random
      next_word = random_word(choices)
      if next_word == :ending
        next_word = random_word(@words_table.words_after(:beginning))
      end
    else
      next_word = choices.max_by {|word, count| count}.first
      next_word = @words_table.words.sort.first if next_word == :ending
    end
    next_word
  end
def word_after ( previous_word ) next_word = nil choices = @words_table . words_after ( previous_word ) if @random next_word = random_word ( choices ) if next_word == :ending next_word = random_word ( @words_table . words_after ( :beginning ) ) end else next_word = choices . max_by { | word , count | count } . first next_word = @words_table . words . sort . first if next_word == :ending end next_word end
Internal: Get a word that comes after the specified one.
Internal : Get a word that comes after the specified one .
# Random mode # Boring mode # Pick the most popular next word. # If the most popular next word is the sentence ending, pick the # alphabetical first word.
previous_word