Eliza
from Paul Gerard
───────────────────────────────────────────────────────────────────────────────
"Older" enthusiasts who learnt BASIC on a mainframe time-sharing system before
micros were either readily available, affordable or, to be honest, much good
anyway, will probably remember this one, the 'mother' of all conversation
programs.
This is a new version that is less inflexible than other BASIC editions, in
fact it produces quite a passable imitation of an intelligent, if very
non-committal conversation, with only an occasional lapse from correct grammar.
When it first came out a lot of quite ridiculous comment was provoked about
the imminent advent of "artificial intelligence", in fact ELIZA or ELIZA-like
programs are still sometimes cited in discussions about AI. In fact of course
it is nothing but a parlour trick. It is however quite an amusing one - and a
grand thing to show non-computing friends (preferably with a suitably
mysterious build up).
If you do not feel like typing in 37k of code - worry not. The program will
work reasonably well, and certainly be quite amusing, with a drastically pruned
"Keys$(N)" array. In other words if you can type in the operational core of the
program (lines 10-1760) and the shorter sets of data then it is quite possible
to make a selection of the DATA lines between 1850 and 3740. The three lines
that will need changing to correspond with the number of keywords or phrases in
use are 570 (the read line), 1190 (which matches one word input) and 1300
(controlling the main matching loop). In each of these the number "190" will
need changing to the number of keys you have in place.
Another point is that the REM lines, while they should be quite helpful in
identifying which part of the program does what, are all quite optional as far
as you typing them in is concerned, as none are used as "addresses" by GOTO or
GOSUB statements.
Assuming that you will probably want to edit the DATA at least in order to
substitute your own family jokes for ours; the following explanations are in
order. Upper and lower case, and the presence or absence of trailing and
leading spaces in the DATA strings ARE significant, and must be typed in
exactly as shown, (although you are at liberty to correct my spelling!).
Also note that the key words and responses are in sets - the key word or
phrase itself in UPPER CASE, and the four responses in normal mixed upper and
lower case. These responses are of two different kinds - the first constitute a
complete reply in themselves, and are terminated with a punctuation mark,
whereas the second, more interesting type take a portion of the user's input to
complete the reply, these responses end abruptly, with no punctuation. Some
very peculiar results will appear if these are not typed in exactly as they are
listed.
Another thing to watch is the actual order in which the keywords are arranged.
Since the program scans the list from top to bottom, and chooses the first key
word or phrase it comes to this order is obviously significant. Most
importantly, a key word or phrase that is a subset of another must occur LATER
in the list, or it will effectively blank out the longer key altogether. For
example the key word "YOU" on its own must come after the key word "YOUR" as
well as any key phrases containing containing "YOU" (e.g. "YOU ARE").
Finally, an apology is probably required for the bad language in some of the
DATA lines. It is an unavoidable fact, however, that many people seem to enjoy
swearing at the computer, and it is fun if the computer responds appropriately.
My twelve year old son (The "Robert" of the insult list), is responsible for
the choice of words - if they are a bit rough for your taste simply substitute
milder ones. In any case note that the program never swears itself, and the
data concerned is for recognition purposes only. (In the interests of our
younger readers and others who could be offended we have removed some words
from lines 3840, 3850 and 4000. For everyone else, you now know where to put
them back!)
Finally a brief note on how to use the finished program. The situation is that
you are visiting your computer psychiatrist. You answer her questions, and ask
your own, in completely natural language, in fact you will get much more
amusing responses if you use proper conversational sentences. Punctuate any
sentences normally, and use upper or lower case as you will.
The program has been fully tested with a five hour "conversation" (over a
period of four days) without any errors being encountered, which is a nice way
of saying that if you get any errors, it must be your long suffering fingers
that caused it!