RubyFlow The Ruby and Rails community linklog


The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

New Gem: Literate Randomizer

I wanted an easy way to generate good, random, near-english prose. There wasn’t a gem that made me happy, so I wrote a new one: Introducing literate_randomizer. (my blog post)

> LiterateRandomizer.paragraph => "Says he slipped rapidly growing in creating. Assure you can't get back. Action of inorganic elements of any binary compressed marked the way up at."


Did you checkout some of the ngrams gems, such as raingrams?

I did not. Thanks for the link :). I’ll take a look.

Raingrams looks great. Yours right? Nice work! I was thinking about trying some tri-grams to see how much better the prose appeared. I also wanted to anchor sentence endings that came from the text. Currently I just truncate when the desired sentence length is reached – unless it is one of the hard-coded preposition words. I spent a decent amount of time working with the random generation part of the code using the simple, core bi-gram model. I may think about using a library like yours at the core and wrapping the random-generation code around it in a future release.

@shaebdavis correct, tri-grams and higher will produce more accurate text. This requires having a greater corpus to train the models against, otherwise you’ll get verbatim training sentences. Also, there’s the problem of enforcing grammar and preventing run-on sentences. You can always enforce minimum / maximum sentence length with a recursive sentence building method. I tried adding some basic random generating methods in Raingrams.

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in