Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple random english sentence generator [closed]

I need a simple random English sentence generator. I need to populate it with my own words, but it needs to be capable of making longer sentences that at least follow the rules of English, even if they don't make sense.

I expect there are millions of them out there, so rather than re-inventing the wheel, I'm hoping you know of a source for one, or a resource that will give me enough information that I don't have to hunt down my rusty English skills.

like image 282
Adam Davis Avatar asked Mar 18 '09 19:03

Adam Davis


3 Answers

You're looking for an implementation of markov chains for English sentences.

A quick Google search for "markov chain sentence generator" returned:

  • http://www.jwz.org/dadadodo/
  • http://code.google.com/p/lorem-ipsum-generator/
  • http://kartoffelsalad.googlecode.com/svn-history/r9/trunk/lib/markov.py
like image 101
Can Berk Güder Avatar answered Oct 25 '22 06:10

Can Berk Güder


I know this is an old question, but as I found it via Google I think it's worth mentioning something like Context Free Grammars in addition to Markov Chains.

My understanding of Markov Chains is that they create the "next" item probabilistically only according to what the "current" item is. Perhaps I'm mistaken, but I don't see how this would ensure that the result would follow grammatical rules.

For instance, I usually see Markov Chains suggested as a way of creating "English sounding" words. If you create a Markov chain using letters from a dataset of English words, the output would be a word that sounds English, but it wouldn't necessarily be a real word. I believe the same would be true of sentences- you can generate something which may sound ok, but it may not be a grammatically correct sentence.

Context Free Grammars (or possibly also Regular Grammars?) might be a better candidate, since they generate sentences according to a defined ruleset. And it would be easy to populate it with your own words, as the original question requests. The downside is that you need to define these rules yourself, rather than relying on a dataset. It's been a long time since I've used a grammar to generate an English sentence, so I don't remember how hard it was to get good / varied responses.

like image 39
Raptormeat Avatar answered Oct 25 '22 05:10

Raptormeat


You might be able to use/modify part of the CS Paper Generator.

like image 31
chills42 Avatar answered Oct 25 '22 05:10

chills42