Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

p4LispDef.txt: ;;; putp ;;; Parameters: ;;; symbol - symbol to be given the property ;;; ht - hash table to store the symbol and its

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

p4LispDef.txt:

;;; putp ;;; Parameters: ;;; symbol - symbol to be given the property ;;; ht - hash table to store the symbol and its property value ;;; value - the property value ;;; Purpose: ;;; stores the property value for the symbol in the specified hash table (defun putp (symbol ht value) (setf (gethash symbol ht) value) ) ;;; getp ;;; Parameters: ;;; symbol - symbol about which we want its property value ;;; ht - hash table to store the symbol and its property value ;;; Purpose: ;;; returns the property value for the symbol in the specified hash table ;;; Returns ;;; The property value for the symbol in the specified hash table. ;;; If not found, NIL is returned. (defun getp (symbol ht) (gethash symbol ht) ) ;;; set up question and diag hash tables (setf question-HT (MAKE-HASH-TABLE)) (setf diag-HT (MAKE-HASH-TABLE)) ;;; since the key for both the symptom and isa hash tables is a list, ;;; we have to tell LISP to use EQUAL for the entry comparison instead of EQ. (setf symptom-HT (MAKE-HASH-TABLE :test #'equal)) (setf isa-HT (MAKE-HASH-TABLE :test #'equal)) ;;; qyn macro ;;; Parameters: ;;; qid - unique ID of a question ;;; ex - the rest of the arguments make up a list which represents the question ;;; Purpose: ;;; Inserts an entry into the question-HT with qid as the key and ex as the value. ;;; Notes: ;;; A macro is used instead of a function so that the arguments do not have to be ;;; quoted. (defmacro qyn (qid &rest ex) `(putp ' ,qid question-HT ' ,ex ) ) ;;; clearSymptoms ;;; Parameters: ;;; n/a ;;; Purpose: ;;; Clears (i.e., deletes) all entries in the symptom-HT. ;;; Returns: ;;; n/a (defun clearSymptoms() (clrhash symptom-HT)) 
CS3723 Pgm 4 LISP- Diagnosis Tree In this LISP assignment, you will provide a medical diagnosis based on a patient's symptoms. Example Medical Diagnosis Tree: 91 Question: PAIN Y: 05 Question: TENDERNESS IN ABDOMEN? Y: 08 Question: X-RAY SHOWS STONES? Y: D9 Diagnosis: TREAT KINDEY STONES N: D8 Diagnosis: SCHEDULE APPENDECTOMY N: 6 Question: PAIN IN THROAT? Y: D7 Diagnosis: ADMINISTER STREP TEST N: 07 Question: FEVER? Y: D6 Diagnosis: TREAT FLU N: D5 Diagnosis: PRESCRIBE ACETAMINOPHEN N: 02 Question: COUGH? Y: D1 Diagnosis:TREAT COMMON COLD N: Q3 Question: FEVER Y: D2 Diagnosis: TREAT FLU N: D3 Diagnosis: THANK YOU FOR VISITING Suppose patient "Alice" has simply a "fever". Based on the diagnosis tree: Q1: Pain?N Therefore, we ask 02: Cough? N Therefore, we ask Q3: Fever? Y So, the diagnosis is "treat flu" Suppose patient "Bob" has the symptom "tenderness in abdomen", what happens? First, we realize the "tenderness in abdomen" is a type of pain when we see the symptom. Therefore, we ask Q5: TENDERNESS IN ABDOMEN? Y Therefore, we ask Q8: X-RAY SHOWS STONES? N So, the diagnosis is "SCHEDULE APPENDECTOMY" In our use of the diagnosis tree, the medic would have done the x-ray and then known an answer to Q8. In our execution we will only know the symptoms before going through the tree. We will represent the diagnosis tree using a hash table entry for each node in the tree: Q1: an entry in a question-HT key: Q1 value: (Q5 Q2 PAIN) Q2: an entry in a question-HT key: 02 value: (D1 03 COUGH) Q5: an entry in a question-HT key: Q5 CS3723 Pgm 4 LISP- Diagnosis Tree In this LISP assignment, you will provide a medical diagnosis based on a patient's symptoms. Example Medical Diagnosis Tree: 91 Question: PAIN Y: 05 Question: TENDERNESS IN ABDOMEN? Y: 08 Question: X-RAY SHOWS STONES? Y: D9 Diagnosis: TREAT KINDEY STONES N: D8 Diagnosis: SCHEDULE APPENDECTOMY N: 6 Question: PAIN IN THROAT? Y: D7 Diagnosis: ADMINISTER STREP TEST N: 07 Question: FEVER? Y: D6 Diagnosis: TREAT FLU N: D5 Diagnosis: PRESCRIBE ACETAMINOPHEN N: 02 Question: COUGH? Y: D1 Diagnosis:TREAT COMMON COLD N: Q3 Question: FEVER Y: D2 Diagnosis: TREAT FLU N: D3 Diagnosis: THANK YOU FOR VISITING Suppose patient "Alice" has simply a "fever". Based on the diagnosis tree: Q1: Pain?N Therefore, we ask 02: Cough? N Therefore, we ask Q3: Fever? Y So, the diagnosis is "treat flu" Suppose patient "Bob" has the symptom "tenderness in abdomen", what happens? First, we realize the "tenderness in abdomen" is a type of pain when we see the symptom. Therefore, we ask Q5: TENDERNESS IN ABDOMEN? Y Therefore, we ask Q8: X-RAY SHOWS STONES? N So, the diagnosis is "SCHEDULE APPENDECTOMY" In our use of the diagnosis tree, the medic would have done the x-ray and then known an answer to Q8. In our execution we will only know the symptoms before going through the tree. We will represent the diagnosis tree using a hash table entry for each node in the tree: Q1: an entry in a question-HT key: Q1 value: (Q5 Q2 PAIN) Q2: an entry in a question-HT key: 02 value: (D1 03 COUGH) Q5: an entry in a question-HT key: Q5

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions