The article describes a Lullian poetry generator in PHP, the idea for which was inspired from Clifford Rickover’s wonderful and eclectic, The Loom of God. The idea is attributed to Ramon Lull, a Spanish theologian, who lived around the 13th century. Lull believed that every branch of knowledge was governed by simple basic principles, and that we could explore all knowledge by evaluating all possible combinations of those principles.
The design for the Lullian poetry sprouts from this premise. The Lullian generator works by randomly selecting words and phrases which are then placed in a pre-defined ‘Semantic Schema’. The philosophical idea being that randomly chosen words can be used to stimulate the mind in producing startling fictional plots and verbal imagery that you might not otherwise consider.
Take the following example short poems generated by the program. Although the resulting poems are nothing like the ones you would ordinarily encounter, the real facet of the poems is their whimsical nature of word combinations, sometimes ridiculously so.
A delightful stranger
A delightful stranger misgiving while riding the fantastic flower.
calmly , the stranger withholding .
The flower thrusting while weeping a eager pleasure.
A fine beast
A fine beast shriving while eating the gentle ocean.
always, the beast melting .
The ocean casting while shooting a fantastic weather.
A agreeable cat
A agreeable cat learning while riding the elated pest.
enormously, the cat springing.
The pest outshining while hanging a calm arm.
The ‘Semantic Schema’ used to generate the above poems is shown below.
A (adjective1) (noun1) A (adjective1) (noun1) (verb) (phrase) the (adjective) (noun2). (adverb), the (noun1) (verb). The (noun2) (verb) (phrase) a (adjective) (noun3).
Now all you need to do is to randomly select a word from a word class (verb, adjective, noun etc.), and replace it with its corresponding placeholder in the schema. The PHP code given below does this automatically for you. Of course you can change the schema to get different types of poem structure.
The code uses five text files for each word class, containing random words and phrases. The quirkiness of the poems depends on these word collection; so if you meticulously select some interesting words for these files, you can create some offbeat poems.
Another thing you can do with the above idea it to use it to generate book or movie titles, by defining an appropriate schema. Some schema templates are shown below, with the examples.
(noun) and (noun)
Example: Pride and Prejudice, Crime and Punishment, War and Peace
The (noun) Who
Example: The Spy Who Loved Me, The Man Who Melted
Of course, to create some nice titles you require some good, selected repository of words. The same method can also be used to generate website domain names. So for example if your business vertical is apparels, you can create a word list of various terms from the apparel industry and let the generator churn out some names.
To play further, you can download the code from below.
Downloads : [downloadcounter(auto-poem)] / File size : [downloadsize(auto-poem)]