class TwoWordSentenceGenerator < SentenceGenerator
  def generate(wordcount)
    sentence = []
    x, y = random_word.split
    sentence << x << y
    (wordcount-1).times do
      sentence << weighted_random("#{sentence[sentence.length-2]} #{sentence.last}")
    end
    sentence.join(' ')
  end
end

require_relative 'sentence-generator'

class TwoWordSentenceGenerator < SentenceGenerator
  def generate(wordcount)
    sentence = []
    sentence.concat(random_word.split)
    (wordcount-1).times do
      sentence.concat(weighted_random(sentence.last(2).join(' ')).split)
    end
    sentence.join(' ')
  end
end

Use concat on split words for sentence
Use concat on split words for sentence

To ensure no multiple word strings get added to the sentence via
random_word, split strings as they come in and concat them to the
array. Need to look into the handling of random_word to see if theres a
way to get rid of the mostly wasteful split operation.
