Simple random english sentence generator [closed]
Asked Answered
J

3

20

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.

Jeffryjeffy answered 18/3, 2009 at 19:48 Comment(0)
S
12

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

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

Supremacy answered 18/3, 2009 at 19:55 Comment(1)
note to self: submit the answer before doing the Google search.Tyronetyrosinase
U
5

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.

Urfa answered 7/9, 2013 at 22:2 Comment(0)
N
4

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

Nosh answered 18/3, 2009 at 19:51 Comment(1)
I used to have a lot of fun with this, works more or less like PolyGenDiaphony

© 2022 - 2024 — McMap. All rights reserved.