TEACH MINI.ELIZA                                  Aaron Sloman, Oct 1997


The file TEACH RESPOND gives a detailed introduction to techniques
required for developing an Eliza program based on Pop-11. This file
provides a skeleton version of the program developed there. You could
copy this file, and edit some of the procedure definitions to produce
your own version of Eliza.

E.g. create a file called 'eliza.p' put the following in it, and
then extend the defintions.

=======================================================================

/*
FILE:            ???Put the file's name here???
AUTHOR:          ???Put your name here???
CREATION DATE:   ???Put the date here???
COURSE:          ???
PURPOSE:         ???
LAST MODIFIED:   ???

*/


;;; ensure that the "!" pattern prefix is compiled

uses readpattern;


;;; declare procedures defined below, so that they can be referred
;;; to in other procedures before they are defined.

vars getname, greet, getproblem, respond, farewell;


define converse();
    ;;; YOU SHOULD PUT A COMMENT HERE, SAYING BRIEFLY
    ;;; WHAT CONVERSE IS INTENDED TO DO
    lvars name, input;

    ;;; Print a message and get user's name
    getname() -> name;

    ;;; Greet the user
    greet(name) =>

    ;;; Now repeatedly get input from the user, and print a
    ;;; response to it.
    repeat
        getproblem() -> input;
    quitif(input = [bye]);
        respond(input) =>
    endrepeat;

    farewell(name) =>
enddefine;


define getname() -> name;
    ;;; This prompts the user to type his/her name, returned as a list

    ;;; Print out a string as a message:
    'Good day. Please type your name, and finish with RETURN' =>

    ;;; read in the user's name as a list of words
    readline() -> name
enddefine;

define greet(name) -> result;
    ;;; ???? add a comment explaining what this does ???
    [Hello ^^name - I am here to help you] -> result;
enddefine;

/*
;;; tests for greet

greet([joe])=>
greet([father christmas])=>

*/

define getproblem() -> sentence;
    ;;; ???? add a comment explaining what this does ???
    oneof(
        [[Please state your problem][Do go on][Tell me more]]) =>

    readline() -> sentence;
enddefine;


define farewell(name) -> result;
    ;;; ???? add a comment explaining what this does ???
    [ I hope you are now feeling better ^^name. Please come again.]
        -> result;
enddefine;


/*
;;; tests for farewell

farewell([joe])=>
farewell([father christmas])=>

*/


define respond(input) -> result;
    ;;; Create a response to the user's input list

    lvars x, y; ;;; local variables

    if  input matches [i hate == ] then
        [perhaps you hate yourself] -> result;
    elseif input matches ! [are you ??x ] then
        [do i seem ^^x] -> result;
    elseif input matches ! [i ??x you] then
        [perhaps in your fantasy we ^^x each other] -> result;
    elseif input matches ! [??x is ??y] then
        [what if ^^x were not ^^y ? ] -> result;

    else
        [please go on] -> result;
    endif;
enddefine;


/*
;;; tests for respond

respond([can you play the tuba]) =>
respond([do you hate your mother?]) =>
respond([i can climb higher than you]) =>
... etc. ...

*/

/*
;;; test command for the whole program

converse();

*/

--- $poplocal/local/teach/mini.eliza
--- Copyright University of Birmingham 1997. All rights reserved. ------
