TEACH PROBLEMS1 Aaron Sloman, Oct 97 Revised 2 Nov 1999 Mid-term exercise, to be handed in to Parveen by Friday 12th Nov 5pm. CONTENTS -- Introduction: Choosing your problem -- Submission (See date at top of this page) -- -- Format for the report1 file -- -- Include tests for your procedures -- -- Attach the checklist to your report -- Problem 1: A version of RESPOND -- -- 1.a. family words -- -- 1.b. angels and prime minister -- -- 1.c. more informative -- -- 1.d. repetitions -- -- 1.e. badword -- -- 1.f. ill to better -- -- Further instructions for Problem 1. -- Problem 2: a simple diary manager -- -- 2.a. what_appointment(day, date, time) -> what -- -- 2.b. when_subject(month, subject) -> appointments -- -- Further instructions for problem 2 -- Problem 3: Extending the diary manager -- -- 3.c. duplicates -- -- 3.d. change_appointments(date, num); -- -- 3.e. A diary manager version of "respond" -- -- Further instructions for problem 3 -- Introduction: Choosing your problem -------------------------------- As indicated in the table of contents there are three problems of increasing difficulty. You can choose the one which corresponds to what you think you can do in about a week. Don't actually start working on this before Monday 8th November, as you may need to learn things from other exercises first (e.g. the RIVER2 teach file is useful for exercise 2). Ideally you should not spend more than four or five days on this as otherwise it could interfere too much with your normal learning. -- Submission (See date at top of this page) -------------------------- When you have finished the exercise, put your report, including both the program code and the documentation in a file in your top level directory which should be called 'report1'. Print out a copy of your report using the following command in VED, with "xxx" replaced by the name of the printer in the lab (e.g. lw-g3): ENTER psprint -p -Pxxx e.g. ENTER psprint -p -Plw-g3 (See TEACH * PRINTING): You will find it best to develop the programs in another file, e.g. a file called 'report1.p' since the '.p' suffix gives the editor useful information, e.g. about formatting. When it is all done you can copy your programs, your tests, and your sample output, into the file report1 and then add explanatory text. NB It is easier to type text into a file which does not have '.p' in its name, because then VED will handle automatic line breaks. Clip the checklist sheet (see below) to the printed copy of your report and hand in both checklist and report by the deadline above. -- -- Format for the report1 file The 'report1' file should have a header giving details including where the file is, what it is for, and which problem you have tackled, your name, and the date. Use "ENTER fileheader" to start it off. The whole file should not print out as more than two or three pages at most --- i.e. at most about 180 lines in the file, perhaps a bit more for the longer problem. This exercise is merely intended to help you consolidate your learning, and give us (and you) clues as to any major misconceptions that may need attention. It also gives you practice in describing a program you have written. It is not meant to be an academic hurdle where performance will affect your future. Non-submission may be taken into account in a way that will be determined later. Note that for your mini-project at the end of term a different format will be required (See TEACH * REPORTS) -- -- Include tests for your procedures After all the procedure definitions include (in a multi-line comment using /* ... */) some tests which check that your version of each procedure behaves as described in the specification of the problem (see below for problem specifications). IMMEDIATELY AFTER EACH TEST COMMAND include the output that it actually produces, also within the comment. (I.e. copy it in from the output.p file.) -- -- Attach the checklist to your report Look at TEACH * PROBLEMS1.CHECKLIST This is a document that will be used in checking your report and you will eventually get it back with ticks and perhaps some additional comments. You will be given a printed copy of this. FILL IN the top part of the problems1.checklist sheet and attach it to the FRONT of your report when you hand it in. One of the demonstrators will write comments which will be returned to you after a week or two. Please try to keep a record of the total time it takes you to do your chosen problem, to help guide me in doing this in future. Write the approximate total number of hours on the checklist sheet. It will not be used in any way that affects you. Make sure your name is on EVERY page and pages are numbered and clipped together, to prevent confusion. Deadline and submission information are at the top of this file. If you haven't finished your selected problem by the deadline, just submit a report on whatever you have have completed rather than letting it drag on and hold up your other work. Choose one of the following problems. How long they will take you depends on your knowledge and skill at programming, which will be different for different students. I hope you can do your chosen problem in no more than about four or five days, including testing and writing the description of what you have done. -- Problem 1: A version of RESPOND ------------------------------------ This problem is suitable for people who may have finished TEACH RESPOND, but have not got far with TEACH RIVER2. It uses the pattern matcher, but not the database. For most students this should be too easy. But it may be useful revision. Produce a version of the respond procedure described in TEACH RESPOND with the properties described below: NB Define ONE procedure which handles all these cases, not several different procedures. -- -- 1.a. family words a. If the user types in a sentence containing one or more of the words mother father sister brother then the program responds with [tell me more about your family] -- -- 1.b. angels and prime minister b. If the user types in a sentence that starts with the word "you" and ends with "me" then the program takes the words in between, stores them in a list and prints out a sentence of the form I always suspected angels ... the prime minister with the words in the list replacing the three dots. E.g. YOU ARE TRYING TO FOOL ME could produce I ALWAYS SUSPECTED ANGELS ARE TRYING TO FOOL THE PRIME MINISTER -- -- 1.c. more informative c. If the user types in a sentence with only one or two words, no matter what they are, the program responds with a request to be more informative. -- -- 1.d. repetitions d. If the user types in a sentence containing the same word twice, the program responds [please do not repeat yourself] -- -- 1.e. badword e. Define a procedure called "badword" taking one word as input and a boolean (true or false) as output. If the word is one of "ill", "bad", or "unwell" it should return the result true, otherwise false. Use the Pop-11 procedure member in your definition. See HELP * MEMBER -- -- 1.f. ill to better (This goes beyond TEACH RESPOND) f. If the user types in a sentence containing one of these phrases feel ill feel bad feel unwell the program prints out the same thing except with the word "better" replacing the word after "feel". Do this using a pattern in which the procedure "badword" occurs as a "restriction procedure" in a pattern, e.g. feel ?word:badword (See TEACH PRIMER and search for "restriction", in CHAPTER 7. Or read HELP * MATCHES) -- -- Further instructions for Problem 1. AT THE TOP OF YOUR REPORT1 FILE, in a comment, say what the procedure respond is for, what sorts of inputs it produces, what sorts of outputs it produces and how it produces the output. Your explanation should not take more than 10 lines: i.e. it is a high level explanation not a detailed line by line explanation. AT THE END OF THE FILE add a SHORT comment describing one way in which your procedure respond could be extended. Say (a) what new sort of capability would be provided (b) how it might be implemented in Pop-11 (don't write the code, just mention the techniques to be used). Can you see any ambiguity in the above problem specification regarding priorities of rules? -- Problem 2: a simple diary manager ---------------------------------- If you have already started using database facilities introduced in TEACH * RIVER2 then you can tackle this problem. Define the following procedures which could be part of a diary manager which stores information about your appointments in the format [ [ ]