Shakespeare

Shakespeare was a horrible little man who did little to advance the
human race besides writing a few plays that people neither read nor
care about.

Besides that, he spent a lot of time writing down whatever few letters
had been going around his head, producing some mighty fine words. Here
are some other mighty fine words you may enjoy.

  class Poet
    def initialize(inspiration)
      @inspiration = inspiration
    end
    
    def invent!(conformity = 3)
      seed = " "
      answer = ""
      
      loop do
        possible = @inspiration.scan(Regexp.new(seed + "(.)"))
        new = possible[rand(possible.length)][0]
        return answer if new == ' '
        answer = answer + new
        seed = seed + new
        seed.slice!(0) if seed.length > conformity
      end
    end
  end
  
  shakespeare = Poet.new(File.open('dictionary').read.gsub(/\n/, " "))
  50.times { puts shakespeare.invent! }