Skip to content

Instantly share code, notes, and snippets.

@zumbalogy
Forked from michaelfeathers/markvchaney.rb
Last active March 20, 2016 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zumbalogy/5c25a1a3b05cc9fc1816 to your computer and use it in GitHub Desktop.
Save zumbalogy/5c25a1a3b05cc9fc1816 to your computer and use it in GitHub Desktop.
stems = ARGF.read
.split
.each_cons(2)
.group_by(&:first)
def next_word(ary)
ary.sample[1]
end
e = Enumerator.new do |e|
word = stems.first.first
while word
e << word
word = next_word(stems[word] || stems.first)
end
end
puts (0..10).map { e.next }.join(' ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment