From Aaron Sloman Sat Apr 29 03:49:27 BST 2000 To: Tom H.... <....> Subject: Haiku generator Tom I've just posted this to comp.ai. It will eventually go via the moderator. Newsgroups: comp.ai References: <8e8v6k$k54$1@mulga.cs.mu.OZ.AU> From: Aaron.Sloman@cs.bham.ac.uk (Aaron Sloman See text for reply address) Subject: Re: WANTED: example source for computer-generated poetry ... Tom .... <....> writes: > Date: 27 Apr 2000 18:53:40 +1000 > > I'm looking for example sourcecode for computer-generated > poetry (specifically haiku), and/or any starting points > for the ai techniques that might be involved in generating > syntactically correct (though not necessarily meaningful) > poetry by computer. Can anyone point me in the right > direction? If you look at http://www.cs.bham.ac.uk/research/poplog/teach/storygrammar It's a light-harted extension of the Pop-11 "teach grammar" file available in http://www.cs.bham.ac.uk/research/poplog/teach/grammar The Pop-11 language is part of Poplog, which is available free of charge with full system sources for a number of platforms, from http://www.cs.bham.ac.uk/research/poplog/freepoplog.html or ftp://ftp.cs.bham.ac.uk/pub/dist/poplog/freepoplog.html The grammar library is included with it and can be used to create parsers or generators for a given context free grammar and lexicon. The storygrammar file shows (among other things) how to define a simple grammar for Haikus, which then (randomly) generates stuff like this: ** [So rapt in the autumn I smell magenta ocean in my heavens Oh many trees have chimed] ** [How magenta in our power I taste welling dawn in your soul Nay our births have missed] ** [So bitter in our spring I slice flossy forms in your sunset Aye two galaxies have lost] ** [All ghostly in my life I frame crass ghosts in all trees Ugh all creatures have switched] ** [All bitter in some age I fleece crass births in the galaxies Aha many paths have bloomed] ** [What ghostly in my leaf I warn bitter age in the galaxies See my ghosts have switched] ** [Ages zany in your spring I mourn abrupt winter in some moon Crash all collisions have cracked] You can improve the quality by more careful subdivision of the lexicon and the grammar into more specialised "matching" cases. that's a way of implicitly putting some (impoverished) semantics into the grammar and lexicon. The Pop-11 language is similar in power to Common Lisp, but with a more conventional syntax which people used to C, Pascal, Java, etc. will probably find easier than Lisp. For more on it see the online primer: http://www.cs.bham.ac.uk/research/poplog/primer/ The parser generator and random sentence generator are included with in the Poplog libraries, but can also be read in http://www.cs.bham.ac.uk/research/poplog/src/master/C.all/lib/lib/grammar.p It makes heavy use of Pop-11's built in list pattern matcher (described in chapter 7 of the primer -- recently replaced by a more powerful and general matcher). The free poplog site has a large amount of AI teaching material with supporting libraries including a graphical interface package and a very flexible agent toolkit. If you try any of this out and have any problems, post them to comp.lang.pop Aaron === Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs/ ) School of Computer Science, The University of Birmingham, B15 2TT, UK EMAIL A.Sloman AT cs.bham.ac.uk (ReadATas@please !) PAPERS: http://www.cs.bham.ac.uk/research/cogaff/