Some comments and cautions

Handling seeks

You may have spotted that there is, in fact, no procedure seeks. If not, look again and you will see that the packaging operation carried out by the superprocedure lonely uses only the word "seeks - though all of the other inputs to the se are, in fact, provided by sub-procedures. You could easily modify this situation.

The data structures

You should have not have too much difficulty getting to grips with the way in which the procedures work. In fact,only two basic patterns are used: (a) procedures which package together the output of subordinate (or daughter) procedures and (b) procedures which output a random selection from a list of words and/or phrases. It is rather perhaps the data structures on which the system depends - the different lists from which random selections are made - which need some comment.

There are two different issues here.

Concatenating words and lists

First, these lists generally contain a mix of words and sub lists (because we are supposing that one and the same constituent in the advertisements may sometimes be a word but sometimes may be more complex). This means, of course, that the sentence primitive which does the gathering together and packaging at various stages is also going to be provided on some occasions with a mix of words and lists as its inputs. A potential problem then is that an se - including the highest level se of lonely - may output a list containg sublists whereas we require lonely in the end to ouput a list composed only of words (which, when the square brackets are removed by print, will be displayed like a normal language sentence).

In fact this particular problem does not surface because of the way in which the data is structured. Sentence does its packaging by concatenating its inputs. You should know by now that this means that if an input to sentence is a list then it is the contents of the list, and not the list as a whole, which are strung together with the rest in a new list. But you will notice that in Lonely Hearts every input list which sentence receives is internally very simple. Every one is composed exclusively of words. Consequently the output of every se of the system - including the highest level se in lonely - will also be no more than a simple list of words as required.

Empty lists and empty words

The second feature which needs some comment is the appearance of the empty list in the input to the first pickrandom in the definition of phone.

op se pickrandom [ [please] [ ] ] <tab> pickrandom [ring call phone telephone dial]

The role of this empty list is to implement the notion of an optional constituent, to handle the fact that the request to ring a number may or equally may not be preceded by the word 'please'. As the notion is handled here, the output is generated not by ensuring that se sometimes takes two inputs and sometimes (abnormally) takes one, but instead by supposing that the first of its two inputs may be, depending on the choice pickrandom makes, either a list containing please or an empty list. Since an empty list A concatenated with a list B is identical to the list B alone, choosing an empty list as an input to sentence is effectively (even if not literally) just like choosing nothing. If you have experimented sufficiently with sentence using both words and lists, you will also realise that it would make no difference to the output provided by the expression se pickrandom [ [please] [ ] ] if the list [please] was replaced by the word "please - to give. [please [ ] ]. Concatenating an object with a word is indistinguishable in outcome from concatenating it with a single word list.

The only thing which prevents us from going even further and replacing the empty list by an empty word is that writing an empty word as a member of a list causes problems. If you try [please " ], you will find that you have indeed created a list of two items but the second is a word composed of the double quote character. And if you try [please ], in the hope that a space will do the trick, you will find you have a one word list containing please because the space is ignored.

As it happens, you can put an empty word in a list indirectly, using sentence. For example,

se "cat "

will give you a two word list and the last of the list is an empty word. (You can verify this by typing, for example, print count se "cat " .) But for most purposes the tactic is not really to be recommended because, as you will see, there is considerable scope for mistaken interpretations of the results whenever they are printed out or displayed on the screen. (It is rather like trying to distinguish the presence of nothing from the absence of anything.)

Ron Brasington
Department of Linguistic Science
The University of Reading