;; ===================================================== ;; SNeRE Verb Algorithm, 1.0 ;; by Joe Salazar - jsalazar@cse.buffalo.edu ;; ;; Future work: ;; Add support for instruments ;; Add support for the 'manner' frame ;; ;; ===================================================== set-mode-3 ;;define-frame Verb(class member) define-frame Transitivity(verb-feature verb type) define-frame CauseEffect(nil cause effect) ;; ================================================== ;; Frames for classification. ;; Many of these are also used by the noun algorithm. ;; ================================================== define-frame Lex(nil lex) define-frame Is-Named(nil object propername) define-frame Is(nil property object) define-frame Isa(nil class member) define-frame Is-a-Kind-of(nil superclass subclass) ;; Equivalency relations. define-frame Equivalent(nil equiv equiv) define-frame Similar(nil similar similar) define-frame are-synonymous(nil synonym synonym) ;; agent acting frames define-frame Does(nil agent act) define-frame action-intrans(nil action1) define-frame action-wrt(nil action1 object1) define-frame action-ditrans(nil action1 object1 indobject1) ;; ===================================================== ;; SNeRE action frames. ;; These frames define the complex and primitive actions ;; used by the algorithm. ;; ===================================================== define-frame DefineVerb(action verb) define-frame DetermineTransitivity(action verb) define-frame DetermineSimilarActions(action verb) define-frame DetermineDirectCause(action verb) define-frame DetermineDirectEffect(action verb) define-frame DetermineActionCause(action verb) define-frame DetermineActionEffect(action verb) define-frame DetermineAgentSuperclass(action verb) define-frame DetermineObjectSuperclass(action verb) define-frame FindVerb(action verb) define-frame FindVerbMembership(action verb) define-frame FindVerbTransitivity(action verb) define-frame FindVerbProperties(action verb) define-frame FindEquivalences(action verb) define-frame FindSimilarActions(action object agent) define-frame FindDirectCause(action verb agent) define-frame FindDirectEffect(action verb agent) define-frame FindActionCause(action verb agent1 agent2) define-frame FindActionEffect(action verb agent1 agent2) define-frame FindAgentSuperclass(action agent) define-frame FindObjectSuperclass(action object) define-frame Say(action object) ;define-frame snsequence2(action object1 object2) ;define-frame snsequence3(action object1 object2 object3) ;define-frame snsequence4(action object1 object2 object3 object4) define-frame snsequence12(action object1 object2 snepsul::object3 snepsul::object4 snepsul::object5 snepsul::object6 snepsul::object7 snepsul::object8 snepsul::object9 snepsul::object10 snepsul::object11 snepsul::object12) ;; ======================================================= ;; Primitive action definitions. ;; ;; The primitive actions used by the algorithm are defined ;; and attached in this section. ;; ======================================================= ^^ (define-primaction Say((object)) (format t "~A~%" object)) ;(define-primaction FindClassMembership ((noun)) ; "Finds all classes in which noun is a member" ; (format t "Attempting to find class membership for ~A~%" noun) ; (format t "~A is a:" noun) ; (format t "~A" (askwh (concatenate 'string "Isa(Lex(" (princ-to-string noun) "),Lex(?x))")))) (define-primaction FindVerb ((verb)) "Print the name of the verb." (format t "Verb: ~A~%" verb)) (define-primaction FindVerbMembership ((verb)) "Find all classes in which verb is a member." (format t "Class: ~A~%" (askwh (concatenate 'string "Isa(Lex(?x),Lex(" (princ-to-string verb) "))")))) (define-primaction FindVerbTransitivity ((verb)) "Print the transitivity of the verb." (format t "Transitivity: ~A~%" (askwh (concatenate 'string "Transitivity(Lex(" (princ-to-string verb) "),?x)")))) (define-primaction FindVerbProperties ((verb)) "Find the properties of the verb." (format t "Properties: ~A~%" (askwh (concatenate 'string "Is(Lex(?x),Lex(" (princ-to-string verb) "))")))) (define-primaction FindAgentSuperclass ((agent)) "Find the properties of the verb." (format t "Agent: ~A~%" (askwh (concatenate 'string "Isa(Lex(?x),Lex(" (princ-to-string agent) "))")))) (define-primaction FindObjectSuperclass ((object)) "Find the properties of the verb." (format t "Object: ~A~%" (askwh (concatenate 'string "Isa(Lex(?x),Lex(" (princ-to-string object) "))")))) (define-primaction FindEquivalences ((verb)) "Find the direct equivalencies with the verb." (format t "Similar Actions: ~A ~A ~A~%" (askwh (concatenate 'string "Equivalent(Lex(" (princ-to-string verb) "),Lex(?x))")) (askwh (concatenate 'string "are-synonymous(Lex(" (princ-to-string verb) "),Lex(?x))")) (askwh (concatenate 'string "Similar(Lex(" (princ-to-string verb) "),Lex(?x))")) )) (define-primaction FindSimilarActions ((object) (agent)) "Find all actions similar to the verb." (format t "Similar Actions: ~A~%" (askwh (concatenate 'string "Does(Lex(" (princ-to-string agent) "), action-wrt(Lex(?x), Lex(" (princ-to-string object) ")))" )))) (define-primaction FindDirectCause ((verb) (agent)) "Find all cause relations with the verb." (format t "Cause: ~A~%" (askwh (concatenate 'string "CauseEffect(Lex(" (princ-to-string verb) "), Does(Lex("(princ-to-string agent)"), action-intrans(Lex(?x)) ))")))) (define-primaction FindDirectEffect ((verb) (agent)) "Find all cause relations with the verb." (format t "Cause: ~A~%" (askwh (concatenate 'string "CauseEffect(Does(Lex(" (princ-to-string agent) "), action-intrans(Lex(?x)) ),Lex("(princ-to-string verb) "))")))) (define-primaction FindActionCause ((verb) (agent1) (agent2)) "Find all action cause relations with the verb." (format t "Action Cause: ~A~%" (askwh (concatenate 'string "CauseEffect(Does(Lex(" (princ-to-string agent1) "), action-intrans(Lex(" (princ-to-string verb) "))), Does(Lex("(princ-to-string agent2)"), action-intrans(Lex(?x)) ))")))) (define-primaction FindActionEffect ((verb) (agent1) (agent2)) "Find all action cause relations with the verb." (format t "Action Effect: ~A~%" (askwh (concatenate 'string "CauseEffect(Does(Lex("(princ-to-string agent2)"), action-intrans(Lex(?x)) ), Does(Lex(" (princ-to-string agent1) "), action-intrans(Lex(" (princ-to-string verb) "))))")))) (attach-primaction do-one do-one do-all do-all believe believe disbelieve disbelieve adopt adopt unadopt unadopt snsequence12 snsequence sniterate sniterate snif snif withall withall withsome withsome ;; user defined primitive actions Say Say FindVerb FindVerb FindVerbProperties FindVerbProperties FindVerbMembership FindVerbMembership FindVerbTransitivity FindVerbTransitivity FindSimilarActions FindSimilarActions FindDirectCause FindDirectCause FindDirectEffect FindDirectEffect FindActionCause FindActionCause FindActionEffect FindActionEffect FindEquivalences FindEquivalences FindAgentSuperclass FindAgentSuperclass FindObjectSuperclass FindObjectSuperclass ) ^^ ;; ============================================ ;; Path definitions for "one or more" relations ;; ============================================ ;; %(define-path subclass (compose subclass (kstar (compose ;; superclass- subclass))) ;; ========================================== ;; Path definition for "superclass" argument. ;; ========================================== define-path superclass (compose superclass (kstar (compose subclass- ! superclass))) ;; ============================================= ;; Path definition for "superordinate" argument. ;; ============================================= define-path class (compose class (kstar (compose subclass- ! superclass))) ;; ======================================= ;; Path definition for equivalency chains. ;; ======================================= define-path equiv (compose equiv (kstar (compose equiv- ! equiv))) ;; ======================================= ;; Path definition for synonym chains. ;; ======================================= define-path synonym (compose synonym (kstar (compose synonym- ! synonym))) ;; ======================================= ;; Path definition for similarity chains. ;; ======================================= define-path similar (compose similar (kstar (compose similar- ! similar))) ;; =========================================== ;; Now add the representation of the sentence. ;; =========================================== ;; ============================================================= ;; Rules for determining superclasses. ;; ;; Checks the action frame of the verb to see if there's an ;; indirect object in use. If so, then the verb is ditransitive. ;; If not, then it checks the action frame to see if the verb ;; is done with respect to an object. If so, then the verb is ;; transitive. If not, then the verb must be instransitive. ;; ============================================================= ;; all(x, y)(I all(v)(Isa(Lex(verb), Lex(v)) => ActPlan(DetermineAgentSuperclass(v), withall(?x, Does(Lex(?x), action-intrans(Lex(v))), FindAgentSuperclass(x)))). all(v)(Isa(Lex(verb), Lex(v)) => ActPlan(DetermineObjectSuperclass(v), withall({?x, ?y}, Does(Lex(?x), action-wrt(Lex(v), Lex(?y))), FindObjectSuperclass(y)))). ;; ============================================================= ;; Rules for determining transitivity. ;; ;; Checks the action frame of the verb to see if there's an ;; indirect object in use. If so, then the verb is ditransitive. ;; If not, then it checks the action frame to see if the verb ;; is done with respect to an object. If so, then the verb is ;; transitive. If not, then the verb must be instransitive. ;; ============================================================= all(v)(Isa(Lex(verb), Lex(v)) => ActPlan(DetermineTransitivity(v), withall({?x, ?y, ?z}, Does(?x, action-ditrans(Lex(v), ?y, ?z)), believe(Transitivity(Lex(v), ditransitive)), withall({?x, ?y}, Does(?x, action-wrt(Lex(v), ?y)), believe(Transitivity(Lex(v), transitive)), believe(Transitivity(Lex(v), intransitive)))))). ;all(v)(Isa(Lex(verb), Lex(v)) => ActPlan(DefineVerb(v), DetermineTransitivity(v))). ;; =================================================================== ;; Rules for determining similar actions. ;; ;; Checks the action frame to see if any equivalent, synonymous or ;; similar actions exist in the network. These actions are represented ;; by using the equiv, synonym and similar frames respectively. If ;; these are not used with respect to the verb then the program scans ;; the network for other actions which could be considered similar. ;; =================================================================== ;; Ensuring that the equivalence relationships trigger by deriving ;; the reverse of every frame. all(x, y)(Equivalent(x, y) => Equivalent(y, x)). all(x, y)(are-synonymous(x, y) => are-synonymous(y, x)). all(x, y)(Similar(x, y) => Similar(y, x)). all(v)(Isa(Lex(verb), Lex(v)) => ActPlan(DetermineSimilarActions(v), withall(?x, are-synonymous(Lex(v), Lex(?x)), FindEquivalences(v), withall(?y, Equivalent(Lex(v), Lex(?y)), FindEquivalences(v), withall(?z, Similar(Lex(v), Lex(?z)), FindEquivalences(v), withall({?t,?w}, Does(?t, action-wrt(Lex(v), Lex(?w))), withall({?a,?b}, Does(Lex(?a), action-wrt(Lex(?b), Lex(w))), FindSimilarActions(w, a) ))))))). ;; ============================================================= ;; Cause and effect frame rules. ;; ;; There are two types of cause and effect relations, direct and ;; action-related. Each is checked individually to determine if ;; they exist. If they do, then the relevant rule is triggered. ;; ;; ============================================================= all(v)(Isa(Lex(verb), Lex(v)) => ActPlan(DetermineDirectCause(v), withall({?x,?y}, CauseEffect(Lex(v), Does(Lex(?x), action-intrans(?y))), FindDirectCause(v, x)))). all(v)(Isa(Lex(verb), Lex(v)) => ActPlan(DetermineDirectEffect(v), withall({?x,?y}, CauseEffect(Does(Lex(?x), action-intrans(?y)), Lex(v)), FindDirectEffect(v, x)))). all(v)(Isa(Lex(verb), Lex(v)) => ActPlan(DetermineActionCause(v), withsome({?x,?y,?z}, CauseEffect(Does(Lex(?x), action-intrans(Lex(v))), Does(Lex(?y), action-intrans(Lex(?z)))), FindActionCause(v, x, y)))). all(v)(Isa(Lex(verb), Lex(v)) => ActPlan(DetermineActionEffect(v), withsome({?x,?y,?z}, CauseEffect(Does(Lex(?x), action-intrans(Lex(?y))), Does(Lex(?z), action-intrans(Lex(v)))), FindActionEffect(v, z, x)))). ;all(v)(Isa(Lex(verb), Lex(v)) => ActPlan(DetermineActionCause(v), ; withall({?w,?x,?y}, CauseEffect(Does(Lex(?w), action-intrans(Lex(v))), ; Does(Lex(?x), action-intrans(?y))), FindActionCause(v, w, x)))). ;all(v)(Isa(Lex(verb), Lex(v)) => ActPlan(DetermineActionCause(v), ; withall({?w,?x,?y}, CauseEffect(Does(Lex(?w), action-intrans(?x)), ; Does(?y, action-intrans(Lex(v)))), ; FindActionEffect(v, w, x)))). ;; ============================================================ ;; Algorithm flow of control. ;; ;; All of the complex actions and primitive actions involved in ;; defining the verb frame are called in sequential order given ;; below. ;; ============================================================ all(v)(Isa(Lex(verb), Lex(v)) => ActPlan(DefineVerb(v), snsequence12(DetermineTransitivity(v), FindVerb(v), FindVerbMembership(v), FindVerbTransitivity(v), FindVerbProperties(v), DetermineDirectCause(v), DetermineDirectEffect(v), DetermineActionCause(v), DetermineActionEffect(v), DetermineSimilarActions(v), DetermineAgentSuperclass(v), DetermineObjectSuperclass(v)))). ;; ====================== ;; Define the verb. ;; ====================== perform DefineVerb(perambulate) ;; End of file.