Writing Nonsense with Perl
I’m looking for a Perl script that uses recursive grammar techniques to generate random sentences. I’ve found several scripts that will throw up a string of text chosen from a pre-made list, but I’d really like to find something that generates sentences on the fly.
Wednesday, September 15th, 1999
I’m looking for a Perl script that uses recursive grammar techniques to generate random sentences. I’ve found several scripts that will throw up a string of text chosen from a pre-made list, but I’d really like to find something that generates sentences on the fly.
I know there’ve been a few non-Perl solutions like Spew and the Dada Engine; what I’m looking for doesn’t have to be that complex — Don Cross’s JavaScript implementation is along the scale I’m thinking.
Anybody here know of something like that?
When I read this posting, I was reminded of the time, 20 years back, I wrote just such a program as a test of the UNIX YACC and LEX tools that I had just read about, called yak (for Yet Another Klugey generator, as well as the meaning of having something that yaks at you). So, I whipped out Damian Conway’s wonderful Parse::RecDescent module, with which I had been playing recently, and generated the spew program in Listing One.