;;;; created 3/21/2004 by clbecker ;;;; last modified 4/16/2004 by clbecker ;;;; ;;;; Evaluate Find-Lists ;;;; ;;;; The functions in this file serve to execute the ;;;; find statements in *Find-List* and store the results ;;;; in a set of association lists based on those in the ;;;; Find-List. ;;;; ;;;; ;;;; Global lists constructed in this module: ;;;; ;;;; *Found-List* ;;;; contains the results of evaluating a find statement ;;;; on each path in the association lists in *Find-List*. ;;;; *Found-List* maintains the same association list structure ;;;; as *Find-List* ;;;; ;;;; example of its contents: ;;;; (... ;;;; (agent ;;;; ((superclass nil) (membership (windstorm typhoon)) ;;;; (property (violent)))) ;;;; (object ;;;; ((superclass nil) (membership (port seaport area city)) ;;;; (property (municipal large)))) ;;;; ...) ;;;; ;;;; ;;;; *ArgsFound* ;;;; contains the results of evaluating a find statement on ;;;; each path in *ArgsToFind* ;;;; ;;;; example of its contents: ;;;; ((verb (m51)) (act (m54 m52)) (agent (b1)) (object (b2)) (indobj nil) ;;;; (instrument nil) (fromObject nil) (toObject nil) (withObject nil)) ;;;; ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; ;;;; Modification History ;;;; ;;;; ;;;; ;;;; 4/16/2004 by cb ;;;; added function evaluateDataProcessingList ;;;; this fills in the list *ProcessingData* ;;;; with results of evaluating the paths in ;;;; *ProcessingDataToFind*. The contents of this ;;;; List are not directly outputted, but rather used ;;;; by the processing functions for other purposes. ;;;; ;;;; ;;;; 4/17/2004 by cb ;;;; ;;;; Added infrastructure for the function evaluateEvalList. ;;;; this function must evaluate the contains of the list *EvalList* ;;;; located in ConstructFindLists.cl. The data retrieved should ;;;; be stored in the list *EvalData*, in the same association list ;;;; structure as *EvalList*. The helper function constructEvalIndexList ;;;; sets up the list *EvalIndexList* containing all the keys from the ;;;; association list *EvalList*. ;;;; ;;;; ;;;; ;;;; ;;;; ;;;; ;;;; ;;;;;;;;;;;;; FUNCTION constructArgList ;;; ;;; This function constructs a list of all the key values of ;;; the arguments of the verb that are used in the association ;;; list, *ArgsToFind*. ;;; ;;; Example of what this list may look like: ;;; (verb act agent object indobj from to ...) ;;; (defun constructArgList (&optional (list *ArgsToFind*)) "Constructs a list of the key values for each list in the ArgsToFind list." (setf *ArgList* (loop for key in list collect (first key))) *ArgList* ) ;;;;;;;;;;;;; FUNCTION constructEvalIndexList ;;; ;;; This function constructs a list of all the key values of ;;; the arguments of the verb that are used in the association ;;; list, *ProcessingDataToFind*. ;;; ;;; Example of what this list may look like: ;;; (example1 example2 ...) ;;; (defun constructEvalList (&optional (list *EvalList*)) "Constructs a list of the key values for each list in the *EvalList* list." (setf *ProcessingDataList* (loop for key in list collect (first key))) *EvalIndexList* ) ;;;;;;;;;;;;; FUNCTION constructMiscList ;;; ;;; This function constructs a list of all the key values ;;; in *MiscItemsToFind* ;;; ;;; Example of what this list may look like: ;;; (synonym cause effect ...) ;;; (defun constructMiscList (&optional (list *MiscItemsToFind*)) "Constructs a list of the key values for each list in the ArgRelsToFind list." (setf *MiscList* (loop for key in list collect (first key))) *MiscList* ) ;;;;;;;;;;;;; FUNCTION constructProcessingDataList ;;; ;;; This function constructs a list of all the key values of ;;; the arguments of the verb that are used in the association ;;; list, *ProcessingDataToFind*. ;;; ;;; Example of what this list may look like: ;;; (actionNode actNode ...) ;;; (defun constructProcessingDataList (&optional (list *ProcessingDataToFind*)) "Constructs a list of the key values for each list in the *ProcessingDataToFind* list." (setf *ProcessingDataList* (loop for key in list collect (first key))) *ProcessingDataList* ) ;;;;;;;;;;;;; FUNCTION constructRelsList ;;; ;;; This function constructs a list of all the key values of ;;; the relations of the arguments of the verb that are used ;;; in the association list, *ArgRelsToFind*. ;;; ;;; Example of what this list may look like: ;;; (membership superclass property ...) ;;; (defun constructRelsList (&optional (list *ArgRelsToFind*)) "Constructs a list of the key values for each list in the ArgRelsToFind list." (setf *RelsList* (loop for key in list collect (first key))) *RelsList* ) ;;;;;;;;;;;;; FUNCTION evaluateFindList ;;; ;;; Arguments: ;;; verb ;;; a symbol; the verb to be defined ;;; ;;; ;;; ;;; This function iterates through the *ArgList*, ;;; and stores the relations listed in *RelsList* ;;; by evaluating the find statements in the *Find-List* ;;; ;;; the results are stored in the double association list, *Found-List* ;;; *Found-List* will look something like this: ;;;(... ;;; (agent ;;; ((superclass nil) (membership (windstorm typhoon)) ;;; (property (violent)))) ;;; (object ;;; ((superclass nil) (membership (port seaport area city)) ;;; (property (municipal large)))) ;;; ...) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; possible future work: ;;; change "find" to something like "deduce" or "findassert" ;;; and test how well it works. (defun evaluateFindList (verb) "Evaluate the find statements in the sets of association lists contained in *Find-List*." ;; Find all relations for each argument ;; (setf *Found-List* (loop for arg in *ArgList* collect (list arg (loop for rel in *RelsList* collect (list rel (first (list #3! ((find ~(first (rest (assoc rel (first (rest (assoc arg *Find-List*)))))) ~verb)))) ) ; end collect rel ) ; end loop for rel in RelsList ) ; end collect arg ) ; end loop for arg in ArgList ) ; end setf *Found-List* ;; append the list of items found for each Misc item from *MiscItemsToFind* (setf *Found-List* (append ;; evaluate misc items (loop for misc in *MiscList* collect (list misc ;; collect results of find statements in ;; a list. The list is sorted by the most frequent ;; to least frequent. (remove-duplicates (sort (setf templist (first (list #3! ((find ~(first (rest (assoc misc *Find-List*))) ~verb))) ) ) ;; sort by frequency #'(lambda (x y) (>= (count x templist) (count y templist))) ) :test #'equal ) ) ;end collect ) ; end loop for arg in MiscList *Found-List*) ;; end append ) ; end setf *Found-List* ;; construct *ArgsFound* list, containing just the nodes ;; of the arguments of the verb (setf *ArgsFound* (loop for arg in *ArgList* collect (list arg ;; collect results of find statements in ;; a list. The list is sorted by the most frequent ;; to least frequent. (remove-duplicates (sort (setf templist (first (list #3! ((find ~(first (rest (assoc arg *ArgsToFind*))) ~verb))) ) ) ;; sort by frequency #'(lambda (x y) (>= (count x templist) (count y templist))) ) :test #'equal ) ) ; end collect ) ; end loop for arg in ArgsList ) ; end setf *ArgsFound* ) ; end function evaluateFindList ;;;;;;;;;;;;; FUNCTION evaluateProcessingDataList ;;; ;;; Arguments: ;;; verb ;;; a symbol; the verb to be defined ;;; ;;; ;;; ;;; This function iterates through the *ProcessingDataList*, ;;; and evaluates each of the paths, storing the results ;;; in the list *ProcessingData* ;;; ;;; This list differs from *Found-List* in that the elements ;;; in *ProcessingData* are not automatically outputted ;;; as the elements in *Found-List* currently are. ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun evaluateProcessingDataList (verb) "Evaluate the find statements in the association list *ProcessingDataToFind*." (setf *ProcessingData* (loop for data in *ProcessingDataList* collect (list data (remove-duplicates (sort (setf templist (first (list #3! ((find ~(first (rest (assoc data *ProcessingDataToFind*))) ~verb))) ) ) ;; sort by frequency #'(lambda (x y) (>= (count x templist) (count y templist))) ) :test #'equal ) ) ; end collect data ) ; end loop for data in *ProcessingDataList* ) ; end setf *ProcessingData* ) ; end function evaluateDataProcessingList ;;;;;;;;;;;;; FUNCTION evaluateEvalList ;;; ;;; Arguments: ;;; verb ;;; a symbol; the verb to be defined ;;; ;;; ;;; ;;; This function iterates through the *EvalIndexList*, ;;; and evaluates each of the paths, storing the results ;;; in the list *EvalData* ;;; ;;; Note: this is not currently fully implemented ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun evaluateEvalList "Evaluate the statements in the association list *EvalList*." (setf *EvalData* (loop for evalitem in *EvalIndexList* collect (list evalitem ;; insert code here to evaluate the cdr of (assoc evalItem *EvalList*) ) ; end collect data ) ; end loop for data in *EvalIndexList* ) ; end setf *EvalData* ) ; end function evaluateEvalList