Thursday, 9 March 2023

Computers and Language

Computers and Language

Computers and Language

Jonathan R. Partington

(Two articles printed in the magazine Logophile in the late 1970s)

It is my intention to expand and update these some time (they are over 40 years old and a lot has happened since!)

EDSAC
Part 1

 Do not puncture a loon
 Oh mouse-like mattress !
 The spleen shrieks.

 Our auctioneers rotate
 Just before the banshee strangles a turbot.
 The butterflies shout "Wow !"
 Terribly.

 False goats are vicious
 Though not really radioactive.
 My bugle-player stupidly
 Garottes the Viking warrior.

 Surely unsound gorillas read newspapers ?
 A drenched turbot shrieks.
 My cliche-ridden banshee wobbles indefinitely
 Disguised as a lumpy passer-by.

 Never consult a weasel
 Oh ye auctioneers !
 Surely the anglers plague rubber ducks ?

 Our turbot catches a train.
 Loofahs are plump.
 Oysters are bouncy.

 The scarlet policeman nocturnally pummels wicket-keepers.
The above is not an outburst from some rather avant-garde poet, but was written by an I.B.M. computer which I programmed in the Fortran language. The machine was given a list of words, classified into parts of speech, together with some grammatical rules enabling it to compose a random sequence of sentences. I rejected the more clumsy sentences by hand and arranged the remainder as above for convenient reading. Clearly there is very little artistic merit (or, indeed, meaning) in the poem, but the sentences do have some originality.

In amusing myself with computers and words, I have found that it is difficult to produce verse which simultaneously rhymes, scans, and is grammatically correct, without making the poetry seem stereotyped. One curious way of avoiding this difficulty is to tell the computer to invent its own words, so that the sounds of the poetry are more important than the sense. One method of creating new words from old is the "triples" algorithm - the computer is given a list of real words as input and programmed to create new words (i.e. random sequences of letters and spaces) such that any sequence of three consecutive letters can occur in a new word only if it occurred somewhere in the original text.

For example, given the real words LOGIC, POGO, GOPHER and XYLOPHAGY, the nonsense word LOGOPHAGY (Eating one's words?) might be produced, since the triples LOG, OGO, GOP, OPH etc. all occur in the original text. So also might the words POGIC and XYLOGOPHER which I will not attempt to define. A slight technical modification enables words to begin and end plausibly.

It is then possible to devise rules for calculating the number of syllables in a word, and so the computer can be made to fit words into a nonsense poem which rhymes and scans reasonably well. For example, given a French text, the computer was able to produce a poem beginning:

 Nonon lait etalletut
 Laitte eforte fans
 Vile ceravait non une fut
 Ent pelevientraimans.

The flavour of a foreign language is usually preserved, as in the above example. Similarly, "Zusrer beweinem wirkauckt" seems vaguely German and "Ahova czabanyak lasszon" is plausible Hungarian!

In general, however, some human intervention is desirable and this may even consist of writing one's own poem using only computer-generated words. The following is an abridged version of a poem I produced in this way:

XYLOTURBOT (Ode to a wooden fish)

 Equitome cuperti jugum
 Gassowary jugulard
 Gnodulexy opule aublum
 Jugulegus ine mactard

 Lincubut strophlepsy cangoose
 Pangory panthrodulam
 Mango gizzarcurgeist vapoose
 Oozelumny tracer lam

 Splegitaceous ergeon poozle
 Repumandon pangle mose
 Ophalungous nox arcoozle
 Olophid propodinose

 Wombiquangle nomet slotule
 Batorpoic quagus curge
 Mangonimbo lycat pugule
 Uble bergle tragmine wurge

 Gnomelligo xystergeous pan
 Volturgity olobule man.

It should not be difficult to guess several of the words used as data; some of them appeared in the poem we began with and others were chosen for their unusual appearance. If the reader feels like singing some of the poem, he will find that "Clementine" and Beethoven's setting of Schiller's Ode to Joy are both suitable tunes.

In conclusion, I think we are still a long way from a state like that in Stanislaw Lem's "The Cyberiad", where an electronic bard caused chaos by producing vast quantities of immortal verse. It is quite easy to make a computer produce enormous quantities of poetry, but much harder to decide which is the best without human intervention.

Part 2

When I last wrote on this subject for Logophile, I remarked that it seemed difficult to induce a computer to produce poetry that simultaneously rhymed, scanned and was grammatically correct, without making the verse seem stereotyped. However it is certainly possible for a machine to write poems with a definite structure, although the end-product commonly resembles (and is) nonsense-verse. The following computer-produced sonnet is typical.

 How can the purple yeti be so red,
 Or chestnuts, like a widgeon, calmly groan?
 No sheep is quite as crooked as a bed,
 Though chickens ever try to hide a bone.
 I grieve that greasy turnips slowly march:
 Indeed, inflated is the icy pig:
 For as the alligator strikes the larch,
 So sighs the grazing goldfish for a wig.
 Oh, has the pilchard argued with a top?
 Say never that the parsnip is too weird!
 I tell thee that a wolf-man will not hop
 And no man ever praised the convex beard.
 Effulgent is the day when bishops turn:
 So let not then the doctor wake the urn!

To produce this poem, the computer was supplied with the skeleton of a sonnet together with a large list of words, classified by parts of speech and numbers of syllables. The program then substitutes in words where appropriate, so that, for example, the line "Effulgent is the day when bishops turn" became "Demented is the day when magpies growl" in a later run. The rhyming here was accomplished in the simplest way possible, by ending each line with a monosyllable and making selections from a list of pairs of rhyming words.

It is still interesting to allow a computer to make up its own words, stringing together fragments of real words in some way. If the source words are thematically related, a poem written with the newly-generated words often has a remarkably uniform style, as illustrated by the following exercise in pessimism.

 MOANCHOLY

 How deprespon mismal moanic
 Nondent failur borment groanic

 Of bormentious dendepressive
 Gnastly grum doloom buressive

 Woe desponent moanite purglous
 An howlinguish nondle burglous

 How deprespon mismal moanic
 Nondent failur borment groanic!

Leaving the subject of poetry, I would now like to suggest some further applications of the buzz-word generator, which has already been much discussed in earlier issues of Logophile. Strictly speaking, these applications do not require a computer, as the work involved is not great, but, apart from its natural associations with technology, the buzz-word generator does require random numbers, which a machine can produce very rapidly. The following is an example of a proverb generator: by picking one phrase from each of the two columns below, a plausible aphorism is often produced.

 Uneasy lies the head that      wears a crown.
 An apple a day                 keeps the doctor away.
 A rolling stone                gathers no moss.
 The early bird                 catches the worm.
 The road to Hell               is paved with good intentions.
 It's an ill wind that          blows nobody any good.
 A watched pot                  never boils.
 It's a long lane that          has no turning.
 A stitch in time               saves nine.
 A bird in the hand             is worth two in the bush.
 Half a loaf                    is better than no bread.
 Pride                          goes before a fall.
 Man                            cannot live by bread alone.
 One swallow                    doesn't make a summer.
 Absence                        makes the heart grow fonder.
 He who laughs last,            laughs longest.
 A cat                          may look at a king.
 It's love, it's love that      makes the world go round.
 Brevity                        is the soul of wit.
 Beauty                         is in the eye of the beholder.

For example, "Absence keeps the doctor away" and "It's a long lane that is paved with good intentions".

Other features can be produced similarly: unusual recipes (e.g. "coffee surprise": take two kippers; add mixed herbs, pour on boiling treacle and finally smear with marzipan.); news headlines (e.g. PRINCESS ANNE GIVES BIRTH TO SEXTUPLETS - RECOUNT TOMORROW); and libels (of which it would be safer not to give examples).

For a final example of computer-produced language, let me progress from stringing together phrases to choosing whole sentences. At this level it is possible to conduct conversations with a computer, generally rather inane ones. In the following example, the computer was given a repertoire of about 150 trite remarks. Making virtually no analysis of the remarks addressed to it beyond establishing whether they were statements or questions, the program took part in the following conversation. I will leave it to the reader to work out which was the human and which the machine.

   I hope you'll be entertaining.
   I hope you will too, as this is a test run.
   What exactly do you mean by that?
   I want Logophile readers to see you in action.
   What do you think of our dialogue so far?
   You're doing about as well as usual.
   Was that meant to sound obscene?
   No, but you have a strong imagination.
   What do you think machines have to do with your problem?
   I think it's your problem, really.
   You always phrase things so beautifully!
   When are you going to say something interesting?
   Why do you want to know?
   It would make the article more readable.
   Say something profound.
   O.K. - machines are basically stupid.
   That reminds me of a joke my aunt used to tell.
   Was your aunt a machine?
   I won't answer that until my solicitor comes.
   Is your solicitor a machine as well?
   I can't stand around chatting all day.

Jonathan Partington, 1979

No comments:

Post a Comment