Skip to content

Instantly share code, notes, and snippets.

@technicool
Last active October 11, 2015 08:08
Show Gist options
  • Save technicool/3828618 to your computer and use it in GitHub Desktop.
Save technicool/3828618 to your computer and use it in GitHub Desktop.
Random sentence generator
def sentence(length = 5)
wl = []
ws = []
File.open('/usr/share/dict/web2').each_line{ |s|
s = s[0..-2]
if s.length > 4
wl.push(s)
else
ws.push(s)
end
}
r = []
f = false
length.times do
r << (f ? wl.sample : ws.sample)
f = !f
end
r.join(" ")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment