class PoliticianSalad::Base

Public Instance Methods

markov_chain() click to toggle source
# File lib/base.rb, line 20
def markov_chain
  markov = MarkyMarkov::TemporaryDictionary.new
  candidate_path = File.join(File.dirname(__FILE__), warehouse_path)
  file = File.open(candidate_path)
  markov.parse_file file

  markov
end
sentence(n_sentences = 1) click to toggle source
# File lib/base.rb, line 6
def sentence(n_sentences = 1)
  markov_chain.generate_n_sentences(n_sentences).capitalize
end
sentences(n_sentences = 1) click to toggle source
# File lib/base.rb, line 10
def sentences(n_sentences = 1)
  markov_chain.generate_n_sentences(n_sentences).split(". ").map do |sentence|
    sentence.capitalize.strip
  end
end
word(n_words = 5) click to toggle source
# File lib/base.rb, line 16
def word(n_words = 5)
  markov_chain.generate_n_words(n_words)
end