Hi, This is my text for Lab 5. I have also attached files new-words.lisp new-rules.lisp semantics.lisp output and this text, lab5.txt as seperate text files. Thanks, Christos. Lab 5 ====== We have appropriately modified files "new-words.lisp" and "new-rules.lisp". All modifications appear at the end of each file, separated in sections according to the test sentence for which each modification was first introduced. To test the sentences, we replaced line (init-syntax) at the end of file "semantics.lisp" with lines (setf *word-semantics-file* "mydirectory/new-words.lisp") (setf *rule-semantics-file* "mydirectory/new-rules.lisp") (load "lab5-sentences") (init-syntax) (test-semantics) and then execute (load "semantics") at the lisp command prompt. Traces for all test sentences are given in file "output". Files "new-words.lisp", "new-rules.lisp", "semantics.lisp" and "output" are attached to this email. Following is a listing of the modifications made in the words file, a listing of the modifications made in the rules file and a listing of the traces for the test sentences. ============================================================================ === Modifications in file "new-words.lisp": ============================================================================ ;;;========================================================================= ;;; The modifications: ;;;========================================================================= ;;; Modifications for test sentence 1: (add-word-semantics 'to 'p 'identity) ;;; Modifications for test sentence 5: (add-word-semantics 'kissed 'v2+passp '(lambda (agent patient) `(kiss :agent ,agent :patient ,patient))) (add-word-semantics 'was 'aux%be+tns '(lambda (verb-frame) (append verb-frame '(:tense past)))) ;;; Modifications for test sentence 6: (add-word-semantics 'by 'p '(lambda ())) ;;; Modifications for test sentence 20: (add-word-semantics 'somebody 'name 'somebody) ;;;========================================================================= ============================================================================ === Modifications in file "new-rules.lisp": ============================================================================ ;;;========================================================================= ;;; The modifications: ;;;========================================================================= ;;; Modifications for test sentence 2: (add-rule-sem '(v+args ==> v3+tns np pp+dat) '(lambda (v3+tns np pp+dat) `(lambda (subj) (funcall ,v3+tns subj ',pp+dat ',np)))) (add-rule-sem '(pp+dat ==> p np) '(lambda (p np) (funcall p np))) ;;; Modifications for test sentence 3: (add-rule-sem '(vbar-tns ==> v3-tns np pp+dat) '(lambda (v3-tns np pp+dat) `(lambda (subj) (funcall ,v3-tns subj ',pp+dat ',np)))) ; ;;; Modifications for test sentence 4: (add-rule-sem '(vbar-tns ==> v3-tns np np) '(lambda (v3-tns np1 np2) `(lambda (subj) (funcall ,v3-tns subj ',np1 ',np2)))) ; ;;; Modifications for test sentence 6: (add-rule-sem '(v+passp ==> v2+passp) 'identity) (add-rule-sem '(vp ==> aux%be+tns v+passp) '(lambda (aux%be+tns v+passp) `(lambda (subj) (append (funcall ,aux%be+tns (funcall ,v+passp 'somebody subj)) '(:type passive))))) ;;; Modifications for test sentence 7: (add-rule-sem '(pp+agby ==> p np) '(lambda (p np) np)) (add-rule-sem '(vp ==> aux%be+tns v+passp pp+agby) '(lambda (aux%be+tns v+passp pp+agby) `(lambda (subj) (append (funcall ,aux%be+tns (funcall ,v+passp ',pp+agby subj)) '(:type passive))))) ;;; Modifications for test sentence 10: (add-rule-sem '(np+wh ==> pronp+wh) 'identity) (add-rule-sem '(q+wh ==> np+wh vp) '(lambda (np+wh vp) (wh-question np+wh (funcall vp np+wh)))) ;;; Modifications for test sentence 11: (add-rule-sem '(q+wh ==> np+wh q/np) '(lambda (np+wh q/np) (wh-question np+wh (funcall q/np np+wh)))) (add-rule-sem '(q/np ==> aux%do%modal np vbar-tns/np) '(lambda (aux%do%modal np vbar-tns/np) `(lambda (patient/beneficiary) (append (funcall ,vbar-tns/np ',np patient/beneficiary) '(:tense past))))) (add-rule-sem '(vbar-tns/np ==> v2-tns np/np) '(lambda (v2-tns np/np) v2-tns)) ;;; Modifications for test sentence 15: (add-rule-sem '(vbar-tns/np ==> v3-tns np pp+dat/np) '(lambda (v3-tns np pp+dat/np) `(lambda (subj beneficiary) (funcall ,v3-tns subj beneficiary ',np)))) (add-rule-sem '(pp+dat/np ==> p np/np) '(lambda (p np/np))) ;;; Modifications for test sentence 16: (add-rule-sem '(vbar-tns/np ==> v3-tns np/np pp+dat) '(lambda (v3-tns np/np pp+dat) `(lambda (subj patient) (funcall ,v3-tns subj ',pp+dat patient)))) ;;;========================================================================= ============================================================================ === File "output": Traces for the 20 test sentences ============================================================================ 1. sentence: "john gave mary fido" syntax: ((root (s (np (np-pro (name john))) (vp (v+args (v3+tns gave) (np (np-pro (name mary))) (np (np-pro (name fido)))))))) semantics: (give :agent john :patient fido :beneficiary mary :tense past) ok. semantics: nil 2. sentence: "john gave fido to mary" syntax: ((root (s (np (np-pro (name john))) (vp (v+args (v3+tns gave) (np (np-pro (name fido))) (pp+dat (p to) (np (np-pro (name mary))))))))) semantics: (give :agent john :patient fido :beneficiary mary :tense past) ok. semantics: nil 3. sentence: "did john give fido to mary" syntax: ((root (q-wh (aux%do%modal (aux%do+tns did)) (np (np-pro (name john))) (vbar-tns (v3-tns give) (np (np-pro (name fido))) (pp+dat (p to) (np (np-pro (name mary)))))))) semantics: yes/no-question (give :agent john :patient fido :beneficiary mary :tense past) yes. semantics: nil 4. sentence: "did john give mary fido" syntax: ((root (q-wh (aux%do%modal (aux%do+tns did)) (np (np-pro (name john))) (vbar-tns (v3-tns give) (np (np-pro (name mary))) (np (np-pro (name fido))))))) semantics: yes/no-question (give :agent john :patient fido :beneficiary mary :tense past) yes. semantics: nil 5. sentence: "mary kissed john" syntax: ((root (s (np (np-pro (name mary))) (vp (v+args (v2+tns kissed) (np (np-pro (name john)))))))) semantics: (kiss :agent mary :patient john :tense past) ok. semantics: nil 6. sentence: "fido was kissed" syntax: ((root (s (np (np-pro (name fido))) (vp (aux%be+tns was) (v+passp (v2+passp kissed)))))) semantics: (kiss :agent somebody :patient fido :tense past :type passive) ok. semantics: nil 7. sentence: "john was kissed by mary" syntax: ((root (s (np (np-pro (name john))) (vp (aux%be+tns was) (v+passp (v2+passp kissed)) (pp+agby (p by) (np (np-pro (name mary)))))))) semantics: (kiss :agent mary :patient john :tense past :type passive) ok. semantics: nil 8. sentence: "john saw fido" syntax: ((root (s (np (np-pro (name john))) (vp (v+args (v2+tns saw) (np (np-pro (name fido)))))))) semantics: (see :agent john :patient fido :tense past) ok. semantics: nil 9. sentence: "john saw mary" syntax: ((root (s (np (np-pro (name john))) (vp (v+args (v2+tns saw) (np (np-pro (name mary)))))))) semantics: (see :agent john :patient mary :tense past) ok. semantics: nil 10. sentence: "who saw fido" syntax: ((root (q+wh (np+wh (pronp+wh who)) (vp (v+args (v2+tns saw) (np (np-pro (name fido)))))))) semantics: wh-question ?who (see :agent ?who :patient fido :tense past) john answer semantics: (john) semantics: nil 11. sentence: "who did john see" syntax: ((root (q+wh (np+wh (pronp+wh who)) (q/np (aux%do%modal (aux%do+tns did)) (np (np-pro (name john))) (vbar-tns/np (v2-tns see) (np/np)))))) semantics: wh-question ?who (see :agent john :patient ?who :tense past) mary and fido answer semantics: (mary fido) semantics: nil 12. sentence: "who gave mary fido" syntax: ((root (q+wh (np+wh (pronp+wh who)) (vp (v+args (v3+tns gave) (np (np-pro (name mary))) (np (np-pro (name fido)))))))) semantics: wh-question ?who (give :agent ?who :patient fido :beneficiary mary :tense past) john answer semantics: (john) semantics: nil 13. sentence: "who gave john fido" syntax: ((root (q+wh (np+wh (pronp+wh who)) (vp (v+args (v3+tns gave) (np (np-pro (name john))) (np (np-pro (name fido)))))))) semantics: wh-question ?who (give :agent ?who :patient fido :beneficiary john :tense past) i don't know. semantics: nil 14. sentence: "who gave fido to mary" syntax: ((root (q+wh (np+wh (pronp+wh who)) (vp (v+args (v3+tns gave) (np (np-pro (name fido))) (pp+dat (p to) (np (np-pro (name mary))))))))) semantics: wh-question ?who (give :agent ?who :patient fido :beneficiary mary :tense past) john answer semantics: (john) semantics: nil 15. sentence: "who did john give fido to" syntax: ((root (q+wh (np+wh (pronp+wh who)) (q/np (aux%do%modal (aux%do+tns did)) (np (np-pro (name john))) (vbar-tns/np (v3-tns give) (np (np-pro (name fido))) (pp+dat/np (p to) (np/np))))))) semantics: wh-question ?who (give :agent john :patient fido :beneficiary ?who :tense past) mary answer semantics: (mary) semantics: nil 16. sentence: "who did john give to mary" syntax: ((root (q+wh (np+wh (pronp+wh who)) (q/np (aux%do%modal (aux%do+tns did)) (np (np-pro (name john))) (vbar-tns/np (v3-tns give) (np/np) (pp+dat (p to) (np (np-pro (name mary))))))))) semantics: wh-question ?who (give :agent john :patient ?who :beneficiary mary :tense past) fido answer semantics: (fido) semantics: nil 17. sentence: "who kissed fido" syntax: ((root (q+wh (np+wh (pronp+wh who)) (vp (v+args (v2+tns kissed) (np (np-pro (name fido)))))))) semantics: wh-question ?who (kiss :agent ?who :patient fido :tense past) somebody answer semantics: (somebody) semantics: nil 18. sentence: "who did mary kiss" syntax: ((root (q+wh (np+wh (pronp+wh who)) (q/np (aux%do%modal (aux%do+tns did)) (np (np-pro (name mary))) (vbar-tns/np (v2-tns kiss) (np/np)))))) semantics: wh-question ?who (kiss :agent mary :patient ?who :tense past) john answer semantics: (john) semantics: nil 19. sentence: "who was kissed by mary" syntax: ((root (q+wh (np+wh (pronp+wh who)) (vp (aux%be+tns was) (v+passp (v2+passp kissed)) (pp+agby (p by) (np (np-pro (name mary)))))))) semantics: wh-question ?who (kiss :agent mary :patient ?who :tense past :type passive) john answer semantics: (john) semantics: nil 20. sentence: "did somebody kiss fido" syntax: ((root (q-wh (aux%do%modal (aux%do+tns did)) (np (np-pro (name somebody))) (vbar-tns (v2-tns kiss) (np (np-pro (name fido))))))) semantics: yes/no-question (kiss :agent somebody :patient fido :tense past) yes. semantics: nil ============================================================================We have appropriately modified files "new-words.lisp" and "new-rules.lisp". All modifications appear at the end of each file, separated in sections according to the test sentence for which each modification was first introduced. To test the sentences, we replaced line (init-syntax) at the end of file "semantics.lisp" with lines (setf *word-semantics-file* "mydirectory/new-words.lisp") (setf *rule-semantics-file* "mydirectory/new-rules.lisp") (load "lab5-sentences") (init-syntax) (test-semantics) and then execute (load "semantics") at the lisp command prompt. Traces for all test sentences are given in file "output". Files "new-words.lisp", "new-rules.lisp", "semantics.lisp" and "output" are attached to this email. Following is a listing of the modifications made in the words file, a listing of the modifications made in the rules file and a listing of the traces for the test sentences. ============================================================================ === Modifications in file "new-words.lisp": ============================================================================ ;;;========================================================================= ;;; The modifications: ;;;========================================================================= ;;; Modifications for test sentence 1: (add-word-semantics 'to 'p 'identity) ;;; Modifications for test sentence 5: (add-word-semantics 'kissed 'v2+passp '(lambda (agent patient) `(kiss :agent ,agent :patient ,patient))) (add-word-semantics 'was 'aux%be+tns '(lambda (verb-frame) (append verb-frame '(:tense past)))) ;;; Modifications for test sentence 6: (add-word-semantics 'by 'p '(lambda ())) ;;; Modifications for test sentence 20: (add-word-semantics 'somebody 'name 'somebody) ;;;========================================================================= ============================================================================ === Modifications in file "new-rules.lisp": ============================================================================ ;;;========================================================================= ;;; The modifications: ;;;========================================================================= ;;; Modifications for test sentence 2: (add-rule-sem '(v+args ==> v3+tns np pp+dat) '(lambda (v3+tns np pp+dat) `(lambda (subj) (funcall ,v3+tns subj ',pp+dat ',np)))) (add-rule-sem '(pp+dat ==> p np) '(lambda (p np) (funcall p np))) ;;; Modifications for test sentence 3: (add-rule-sem '(vbar-tns ==> v3-tns np pp+dat) '(lambda (v3-tns np pp+dat) `(lambda (subj) (funcall ,v3-tns subj ',pp+dat ',np)))) ; ;;; Modifications for test sentence 4: (add-rule-sem '(vbar-tns ==> v3-tns np np) '(lambda (v3-tns np1 np2) `(lambda (subj) (funcall ,v3-tns subj ',np1 ',np2)))) ; ;;; Modifications for test sentence 6: (add-rule-sem '(v+passp ==> v2+passp) 'identity) (add-rule-sem '(vp ==> aux%be+tns v+passp) '(lambda (aux%be+tns v+passp) `(lambda (subj) (append (funcall ,aux%be+tns (funcall ,v+passp 'somebody subj)) '(:type passive))))) ;;; Modifications for test sentence 7: (add-rule-sem '(pp+agby ==> p np) '(lambda (p np) np)) (add-rule-sem '(vp ==> aux%be+tns v+passp pp+agby) '(lambda (aux%be+tns v+passp pp+agby) `(lambda (subj) (append (funcall ,aux%be+tns (funcall ,v+passp ',pp+agby subj)) '(:type passive))))) ;;; Modifications for test sentence 10: (add-rule-sem '(np+wh ==> pronp+wh) 'identity) (add-rule-sem '(q+wh ==> np+wh vp) '(lambda (np+wh vp) (wh-question np+wh (funcall vp np+wh)))) ;;; Modifications for test sentence 11: (add-rule-sem '(q+wh ==> np+wh q/np) '(lambda (np+wh q/np) (wh-question np+wh (funcall q/np np+wh)))) (add-rule-sem '(q/np ==> aux%do%modal np vbar-tns/np) '(lambda (aux%do%modal np vbar-tns/np) `(lambda (patient/beneficiary) (append (funcall ,vbar-tns/np ',np patient/beneficiary) '(:tense past))))) (add-rule-sem '(vbar-tns/np ==> v2-tns np/np) '(lambda (v2-tns np/np) v2-tns)) ;;; Modifications for test sentence 15: (add-rule-sem '(vbar-tns/np ==> v3-tns np pp+dat/np) '(lambda (v3-tns np pp+dat/np) `(lambda (subj beneficiary) (funcall ,v3-tns subj beneficiary ',np)))) (add-rule-sem '(pp+dat/np ==> p np/np) '(lambda (p np/np))) ;;; Modifications for test sentence 16: (add-rule-sem '(vbar-tns/np ==> v3-tns np/np pp+dat) '(lambda (v3-tns np/np pp+dat) `(lambda (subj patient) (funcall ,v3-tns subj ',pp+dat patient)))) ;;;========================================================================= ============================================================================ === File "output": Traces for the 20 test sentences ============================================================================ 1. sentence: "john gave mary fido" syntax: ((root (s (np (np-pro (name john))) (vp (v+args (v3+tns gave) (np (np-pro (name mary))) (np (np-pro (name fido)))))))) semantics: (give :agent john :patient fido :beneficiary mary :tense past) ok. semantics: nil 2. sentence: "john gave fido to mary" syntax: ((root (s (np (np-pro (name john))) (vp (v+args (v3+tns gave) (np (np-pro (name fido))) (pp+dat (p to) (np (np-pro (name mary))))))))) semantics: (give :agent john :patient fido :beneficiary mary :tense past) ok. semantics: nil 3. sentence: "did john give fido to mary" syntax: ((root (q-wh (aux%do%modal (aux%do+tns did)) (np (np-pro (name john))) (vbar-tns (v3-tns give) (np (np-pro (name fido))) (pp+dat (p to) (np (np-pro (name mary)))))))) semantics: yes/no-question (give :agent john :patient fido :beneficiary mary :tense past) yes. semantics: nil 4. sentence: "did john give mary fido" syntax: ((root (q-wh (aux%do%modal (aux%do+tns did)) (np (np-pro (name john))) (vbar-tns (v3-tns give) (np (np-pro (name mary))) (np (np-pro (name fido))))))) semantics: yes/no-question (give :agent john :patient fido :beneficiary mary :tense past) yes. semantics: nil 5. sentence: "mary kissed john" syntax: ((root (s (np (np-pro (name mary))) (vp (v+args (v2+tns kissed) (np (np-pro (name john)))))))) semantics: (kiss :agent mary :patient john :tense past) ok. semantics: nil 6. sentence: "fido was kissed" syntax: ((root (s (np (np-pro (name fido))) (vp (aux%be+tns was) (v+passp (v2+passp kissed)))))) semantics: (kiss :agent somebody :patient fido :tense past :type passive) ok. semantics: nil 7. sentence: "john was kissed by mary" syntax: ((root (s (np (np-pro (name john))) (vp (aux%be+tns was) (v+passp (v2+passp kissed)) (pp+agby (p by) (np (np-pro (name mary)))))))) semantics: (kiss :agent mary :patient john :tense past :type passive) ok. semantics: nil 8. sentence: "john saw fido" syntax: ((root (s (np (np-pro (name john))) (vp (v+args (v2+tns saw) (np (np-pro (name fido)))))))) semantics: (see :agent john :patient fido :tense past) ok. semantics: nil 9. sentence: "john saw mary" syntax: ((root (s (np (np-pro (name john))) (vp (v+args (v2+tns saw) (np (np-pro (name mary)))))))) semantics: (see :agent john :patient mary :tense past) ok. semantics: nil 10. sentence: "who saw fido" syntax: ((root (q+wh (np+wh (pronp+wh who)) (vp (v+args (v2+tns saw) (np (np-pro (name fido)))))))) semantics: wh-question ?who (see :agent ?who :patient fido :tense past) john answer semantics: (john) semantics: nil 11. sentence: "who did john see" syntax: ((root (q+wh (np+wh (pronp+wh who)) (q/np (aux%do%modal (aux%do+tns did)) (np (np-pro (name john))) (vbar-tns/np (v2-tns see) (np/np)))))) semantics: wh-question ?who (see :agent john :patient ?who :tense past) mary and fido answer semantics: (mary fido) semantics: nil 12. sentence: "who gave mary fido" syntax: ((root (q+wh (np+wh (pronp+wh who)) (vp (v+args (v3+tns gave) (np (np-pro (name mary))) (np (np-pro (name fido)))))))) semantics: wh-question ?who (give :agent ?who :patient fido :beneficiary mary :tense past) john answer semantics: (john) semantics: nil 13. sentence: "who gave john fido" syntax: ((root (q+wh (np+wh (pronp+wh who)) (vp (v+args (v3+tns gave) (np (np-pro (name john))) (np (np-pro (name fido)))))))) semantics: wh-question ?who (give :agent ?who :patient fido :beneficiary john :tense past) i don't know. semantics: nil 14. sentence: "who gave fido to mary" syntax: ((root (q+wh (np+wh (pronp+wh who)) (vp (v+args (v3+tns gave) (np (np-pro (name fido))) (pp+dat (p to) (np (np-pro (name mary))))))))) semantics: wh-question ?who (give :agent ?who :patient fido :beneficiary mary :tense past) john answer semantics: (john) semantics: nil 15. sentence: "who did john give fido to" syntax: ((root (q+wh (np+wh (pronp+wh who)) (q/np (aux%do%modal (aux%do+tns did)) (np (np-pro (name john))) (vbar-tns/np (v3-tns give) (np (np-pro (name fido))) (pp+dat/np (p to) (np/np))))))) semantics: wh-question ?who (give :agent john :patient fido :beneficiary ?who :tense past) mary answer semantics: (mary) semantics: nil 16. sentence: "who did john give to mary" syntax: ((root (q+wh (np+wh (pronp+wh who)) (q/np (aux%do%modal (aux%do+tns did)) (np (np-pro (name john))) (vbar-tns/np (v3-tns give) (np/np) (pp+dat (p to) (np (np-pro (name mary))))))))) semantics: wh-question ?who (give :agent john :patient ?who :beneficiary mary :tense past) fido answer semantics: (fido) semantics: nil 17. sentence: "who kissed fido" syntax: ((root (q+wh (np+wh (pronp+wh who)) (vp (v+args (v2+tns kissed) (np (np-pro (name fido)))))))) semantics: wh-question ?who (kiss :agent ?who :patient fido :tense past) somebody answer semantics: (somebody) semantics: nil 18. sentence: "who did mary kiss" syntax: ((root (q+wh (np+wh (pronp+wh who)) (q/np (aux%do%modal (aux%do+tns did)) (np (np-pro (name mary))) (vbar-tns/np (v2-tns kiss) (np/np)))))) semantics: wh-question ?who (kiss :agent mary :patient ?who :tense past) john answer semantics: (john) semantics: nil 19. sentence: "who was kissed by mary" syntax: ((root (q+wh (np+wh (pronp+wh who)) (vp (aux%be+tns was) (v+passp (v2+passp kissed)) (pp+agby (p by) (np (np-pro (name mary)))))))) semantics: wh-question ?who (kiss :agent mary :patient ?who :tense past :type passive) john answer semantics: (john) semantics: nil 20. sentence: "did somebody kiss fido" syntax: ((root (q-wh (aux%do%modal (aux%do+tns did)) (np (np-pro (name somebody))) (vbar-tns (v2-tns kiss) (np (np-pro (name fido))))))) semantics: yes/no-question (kiss :agent somebody :patient fido :tense past) yes. semantics: nil ============================================================================ ;;; -*- mode: lisp; package: gpsg; base: 10; syntax: common-lisp -*- ;;; ;;; semantic roles/thematic roles/lexical conceptual structures ;;; agent - j gave m a book ;;; patient/theme - j gave m a book ;;; beneficiary/goal - j gave m a book ;;; location - j put a book on the table ;;; proposition - j thinks that mary saw bill ;;; objective - j told mary to eat ice cream ;;; nouns ; (in-package 'gpsg :use '(lisp)) (add-word-semantics 'bill 'name 'bill) (add-word-semantics 'fido 'name 'fido) (add-word-semantics 'fred 'name 'fred) (add-word-semantics 'jane 'name 'jane) (add-word-semantics 'john 'name 'john) (add-word-semantics 'mary 'name 'mary) (add-word-semantics 'rusty 'name 'rusty) ;;; noun phrases (defun add-noun (noun number) (add-word-semantics noun 'n `(lambda (det ap?) `(,',noun :definite? ,det :number ,',number ,@(if ap? `(:mod ,ap?)))))) (defun add-mass-noun (noun) (add-word-semantics noun 'n+mass `(lambda (ap?) `(,',noun :definite? nil :number mass ,@(if ap? `(:mod ,ap?)))))) (add-noun 'book 'singular) (add-noun 'books 'plural) (add-noun 'cadillac 'singular) (add-noun 'car 'singular) (add-noun 'cats 'plural) (add-noun 'cities 'plural) (add-noun 'city 'singular) (add-noun 'communist 'singular) (add-noun 'conference 'singular) (add-noun 'corner 'singular) (add-noun 'cows 'plural) (add-noun 'dog 'singular) (add-noun 'drugs 'plural) (add-noun 'eggplant 'singular) (add-mass-noun 'eggplant) (add-noun 'exam 'singular) (add-noun 'fact 'singular) (add-noun 'friends 'plural) (add-noun 'guy 'singular) (add-noun 'horses 'plural) (add-noun 'kennel 'singular) (add-noun 'keys 'plural) (add-noun 'letter 'singular) (add-noun 'man 'singular) (add-noun 'mets 'plural) (add-noun 'park 'singular) (add-noun 'pencil 'singular) (add-noun 'pot 'singular) (add-noun 'redsox 'singular) (add-noun 'room 'singular) (add-noun 'table 'singular) (add-noun 'tax 'singular) (add-noun 'teams 'plural) (add-noun 'theory 'singular) (add-noun 'tree 'singular) (add-noun 'tune 'singular) (add-noun 'volume 'singular) (add-noun 'volumes 'plural) (add-noun 'werewolf 'singular) (add-noun 'woman 'singular) (add-noun 'years 'plural) ;;; determiners (add-word-semantics 'the 'det t) (add-word-semantics 'this 'det t) ;demonstrative? (add-word-semantics 'a 'det nil) (add-word-semantics 'an 'det nil) (add-word-semantics 'who 'pronp+wh '?who) (add-word-semantics 'what 'pronp+wh '?what) (add-word-semantics 'where 'adv+wh '(:locative ?where)) ;;; verbs (defmacro add-v1 (v-tns v+past v+present) `(progn (add-word-semantics ',v-tns 'v1-tns `(lambda (agent) `(,',',v-tns :agent ,agent))) (add-word-semantics ',v+past 'v1+tns `(lambda (agent) `(,',',v-tns :agent ,agent :tense past))) (add-word-semantics ',v+present 'v1+tns `(lambda (agent) `(,',',v-tns :agent ,agent :tense present))))) (add-v1 come came comes) (add-v1 drive drove drives) (add-v1 eat ate eats) (add-v1 return returned returns) (add-v1 sing sang sings) (add-v1 sleep slept sleeps) (add-v1 talk talked talks) (defmacro add-v2 (v-tns v+past v+present) `(progn (add-word-semantics ',v-tns 'v2-tns `(lambda (agent patient) `(,',',v-tns :agent ,agent :patient ,patient))) (add-word-semantics ',v+past 'v2+tns `(lambda (agent patient) `(,',',v-tns :agent ,agent :patient ,patient :tense past))) (add-word-semantics ',v+present 'v2+tns `(lambda (agent patient) `(,',',v-tns :agent ,agent :patient ,patient :tense present))))) ;;new (add-v2 kiss kissed kisses) (add-v2 eat ate eats) (add-v2 buy bought buys) (add-v2 catch caught catches) (add-v2 chase chased chases) (add-v2 compute computed computes) (add-v2 drive drove drives) (add-v2 find found finds) (add-v2 hate hated hates) (add-v2 keep kept keeps) (add-v2 kill killed kills) (add-v2 like liked likes) (add-v2 love loved loves) (add-v2 make made makes) (add-v2 pass passed passes) (add-v2 please pleased pleases) (add-v2 sing sang sings) (add-v2 see saw sees) (add-v2 support supported supports) (add-v2 surprise surprised surprises) (add-v2 visit visited visits) (defmacro add-v3 (v-tns v+past v+present) `(progn (add-word-semantics ',v-tns 'v3-tns `(lambda (agent beneficiary patient) `(,',',v-tns :agent ,agent :patient ,patient :beneficiary ,beneficiary))) (add-word-semantics ',v+past 'v3+tns `(lambda (agent beneficiary patient) `(,',',v-tns :agent ,agent :patient ,patient :beneficiary ,beneficiary :tense past))) (add-word-semantics ',v+present 'v3+tns `(lambda (agent beneficiary patient) `(,',',v-tns :agent ,agent :patient ,patient :beneficiary ,beneficiary :tense present))))) (add-v3 give gave gives) (add-word-semantics 'put 'v4+tns '(lambda (agent patient locative) `(put :agent ,agent :patient ,patient :locative ,locative :tense past))) (add-word-semantics 'liked 'v5+tns '(lambda (agent objective) `(like :agent ,agent :objective ,objective :tense past))) (add-word-semantics 'told 'v6+tns '(lambda (agent patient objective) `(tell :agent ,agent :patient ,patient :objective ,objective :tense past))) (add-word-semantics 'thinks 'v8+tns '(lambda (agent proposition) `(think :agent ,agent :proposition ,proposition :tense present))) (add-word-semantics 'regretted 'v9+tns '(lambda (agent factive) `(regret :agent ,agent :factive ,factive :tense past))) (add-word-semantics 'looked 'v10+tns '(lambda (individual state-of-being) `(look :individual ,individual :state-of-being ,state-of-being :tense past))) (add-word-semantics 'wondered 'v11+tns '(lambda (agent object) `(wonder :agent ,agent :object ,object :tense past))) (add-word-semantics 'offered 'v12+tns '(lambda (agent object) `(offer :agent ,agent :object ,object :tense past))) ;;; preposition (add-word-semantics 'in 'p '(lambda (location) `(lambda (frame) (add-feature frame :locative '(:relation in :location ,location))))) (add-word-semantics 'under 'p '(lambda (location) `(lambda (frame) (add-feature frame :locative '(:relation under :location ,location))))) (add-word-semantics 'on 'p+loc '(lambda (location) `(on ,location))) (add-word-semantics 'of 'p '(lambda (source) `(of ,source))) ;;; adjectives (add-word-semantics 'rabid 'a '(rabid)) (add-word-semantics 'raw 'a '(raw)) (add-word-semantics 'smart 'a '(smart)) (add-word-semantics 'red 'a '(:color red)) (add-word-semantics 'blue 'a '(:color blue)) (add-word-semantics 'green 'a '(:color green)) (add-word-semantics 'yellow 'a '(:color yellow)) ;;; predicate adjective (add-word-semantics 'suspicious 'a '(lambda (source) (cond (source `(suspicious :source ,source)) (t `(suspicious :source something))))) ;;; aux and modal (add-word-semantics 'did 'aux%do+tns '(lambda (verb-frame) (append verb-frame '(:tense past)))) (add-word-semantics 'does 'aux%do+tns '(lambda (verb-frame) (append verb-frame '(:tense present)))) (add-word-semantics 'can 'modal '(lambda (verb-frame) (append verb-frame '(:mood can :tense present)))) ;;; form words (add-word-semantics 'to '*to '(lambda ())) (add-word-semantics 'that '*that '(lambda ())) (add-word-semantics 'whether 'comp+wh '(lambda ())) ;;;========================================================================= ;;; The modifications: ;;;========================================================================= ;;; Modifications for test sentence 1: (add-word-semantics 'to 'p 'identity) ;;; Modifications for test sentence 5: (add-word-semantics 'kissed 'v2+passp '(lambda (agent patient) `(kiss :agent ,agent :patient ,patient))) (add-word-semantics 'was 'aux%be+tns '(lambda (verb-frame) (append verb-frame '(:tense past)))) ;;; Modifications for test sentence 6: (add-word-semantics 'by 'p '(lambda ())) ;;; Modifications for test sentence 20: (add-word-semantics 'somebody 'name 'somebody) ;;;========================================================================= ;;; -*- mode: lisp; package: gpsg; base: 10; syntax: common-lisp -*- ;;; root ; (in-package 'gpsg :use '(lisp)) (add-rule-sem '(root ==> s) '(lambda (s) (process-sentence s))) (add-rule-sem '(root ==> q+wh) '(lambda (q+wh) q+wh)) (add-rule-sem '(root ==> q-wh) '(lambda (q-wh) (y/n-question q-wh))) ;;; s and q ;; declarative s (add-rule-sem '(s ==> np vp) '(lambda (np vp) (funcall vp np))) ;;; yes-no question (add-rule-sem '(q-wh ==> aux%do%modal np vbar-tns) '(lambda (aux%do%modal np vbar-tns) (funcall aux%do%modal (funcall vbar-tns np)))) ;;; where did ... (add-rule-sem '(q+wh ==> advp+wh q-wh) '(lambda (advp+wh q-wh) (wh-question (second advp+wh) (add-feature q-wh (first advp+wh) (second advp+wh))))) ;;; np (add-rule-sem '(np ==> np-pro) #'identity) (add-rule-sem '(np-pro ==> name) #'identity) (add-rule-sem '(np-pro ==> det ap? n) '(lambda (det ap? n) (funcall n det ap?))) (add-rule-sem '(np-pro ==> ap? n+mass) '(lambda (ap? n+mass) (funcall n+mass ap?))) ;;; np+wh and advp+wh (add-rule-sem '(np+wh ==> pronp+wh) #'identity) (add-rule-sem '(advp+wh ==> adv+wh) #'identity) ;;; ap (add-rule-sem '(ap? ==> ap ap?) '(lambda (ap ap?) (cond ((null ap?) ap) (t `(,@ap :mod ,ap?))))) ; (t (append (append ap '(:mod)) (list ap?)))))) (add-rule-sem '(ap? ==> ) '(lambda ())) (add-rule-sem '(ap ==> a) #'identity) ;;; vp (add-rule-sem '(vp ==> v+args) '(lambda ( v+args) `(lambda (subj) (funcall ,v+args subj)))) ; (add-rule-sem '(vp ==> aux%do%modal vbar-tns) '(lambda (aux%do%modal vbar-tns) `(lambda (subj) (funcall ,aux%do%modal (funcall ,vbar-tns subj))))) ;;; v+args and vbar-tns (add-rule-sem '(v+args ==> v1+tns) '(lambda (v1+tns) `(lambda (subj) (funcall ,v1+tns subj)))) (add-rule-sem '(v+args ==> v1+tns pp) '(lambda (v1+tns pp) `(lambda (subj) (funcall ,pp (funcall ,v1+tns subj))))) (add-rule-sem '(vbar-tns ==> v1-tns) '(lambda ( v1-tns) `(lambda (subj) (funcall ,v1-tns subj)))) ; (add-rule-sem '(v+args ==> v2+tns np) '(lambda (v2+tns np) `(lambda (subj) (funcall ,v2+tns subj ',np)))) (add-rule-sem '(v+args ==> v2+tns np pp) '(lambda (v2+tns np pp) `(lambda (subj) (funcall ,pp (funcall ,v2+tns subj ',np))))) (add-rule-sem '(vbar-tns ==> v2-tns np) '(lambda (v2-tns np) `(lambda (subj) (funcall ,v2-tns subj ',np)))) (add-rule-sem '(v+args ==> v3+tns np np) '(lambda (v3+tns np1 np2) `(lambda (subj) (funcall ,v3+tns subj ',np1 ',np2)))) (add-rule-sem '(v+args ==> v4+tns np pp+loc) '(lambda (v4+tns np pp+loc) `(lambda (subj) (funcall ,v4+tns subj ',np ',pp+loc)))) ; v+args = v5 vbar-fin -- vbar-fin = *to vbar-tns -- vbar-tns = vxx-tns args (add-rule-sem '(v+args ==> v5+tns vbar-fin) '(lambda (v5+tns vbar-fin) `(lambda (subj) (funcall ,v5+tns subj (funcall ,vbar-fin subj))))) (add-rule-sem '(v+args ==> v6+tns np vbar-fin) '(lambda (v6+tns np vbar-fin) `(lambda (subj) (funcall ,v6+tns subj ',np (funcall ,vbar-fin ',np))) )) (add-rule-sem '(v+args ==> v8+tns sbar%that) '(lambda (v8+tns sbar%that) `(lambda (subj) (funcall ,v8+tns subj ',sbar%that)))) (add-rule-sem '(v+args ==> v9+tns sbar%that%fact) '(lambda (v9+tns sbar%that) `(lambda (subj) (funcall ,v9+tns subj ',sbar%that)))) (add-rule-sem '(v+args ==> v10+tns ap%pred) '(lambda (v10+tns ap%pred) `(lambda (subj) (funcall ,v10+tns subj ',ap%pred)))) (add-rule-sem '(v+args ==> v11+tns qemb) '(lambda (v11+tns qemb) `(lambda (subj) (funcall ,v11+tns subj ',qemb)))) (add-rule-sem '(v+args ==> v12+tns sbar%for) '(lambda (v12+tns sbar%for) `(lambda (subj) (funcall ,v12+tns subj ',sbar%for)))) ;;; vbar-fin (add-rule-sem '(vbar-fin ==> *to vbar-tns) '(lambda (*to vbar-tns) `(lambda (subj) (funcall ,vbar-tns subj)))) ;;; qemb (add-rule-sem '(qemb ==> sbar+wh%comp) #'identity) ;;; ap%pred (add-rule-sem '(ap%pred ==> a pp?) '(lambda (a pp?) (funcall a pp?))) ;;; pp (add-rule-sem '(pp+loc ==> p+loc np) '(lambda (p+loc np) (funcall p+loc np))) (add-rule-sem '(pp? ==> pp) '(lambda (pp) pp)) (add-rule-sem '(pp ==> p np) '(lambda (p np) (funcall p np))) ;;; sbar%that (add-rule-sem '(sbar%that ==> comp%that s) '(lambda (comp%that s) s)) ;;; sbar+wh%comp (add-rule-sem '(sbar+wh%comp ==> qcomp s) '(lambda (qcomp s) s)) (add-rule-sem '(qcomp ==> comp+wh) #'identity) ;;; sbar%for (add-rule-sem '(sbar%for ==> comp%for np vbar-fin) '(lambda (comp%for np vbar-fin) (funcall vbar-fin np))) ;;; aux (add-rule-sem '(aux%do%modal ==> aux%do+tns) #'identity) (add-rule-sem '(aux%do%modal ==> modal) #'identity) ;;; the empties (add-rule-sem '(np/np ==> ) '(lambda ())) ;;;==================================================================== ;;; The modifications: ;;;==================================================================== ;;; Modifications for test sentence 2: (add-rule-sem '(v+args ==> v3+tns np pp+dat) '(lambda (v3+tns np pp+dat) `(lambda (subj) (funcall ,v3+tns subj ',pp+dat ',np)))) (add-rule-sem '(pp+dat ==> p np) '(lambda (p np) (funcall p np))) ;;; Modifications for test sentence 3: (add-rule-sem '(vbar-tns ==> v3-tns np pp+dat) '(lambda (v3-tns np pp+dat) `(lambda (subj) (funcall ,v3-tns subj ',pp+dat ',np)))) ; ;;; Modifications for test sentence 4: (add-rule-sem '(vbar-tns ==> v3-tns np np) '(lambda (v3-tns np1 np2) `(lambda (subj) (funcall ,v3-tns subj ',np1 ',np2)))) ; ;;; Modifications for test sentence 6: (add-rule-sem '(v+passp ==> v2+passp) 'identity) (add-rule-sem '(vp ==> aux%be+tns v+passp) '(lambda (aux%be+tns v+passp) `(lambda (subj) (append (funcall ,aux%be+tns (funcall ,v+passp 'somebody subj)) '(:type passive))))) ;;; Modifications for test sentence 7: (add-rule-sem '(pp+agby ==> p np) '(lambda (p np) np)) (add-rule-sem '(vp ==> aux%be+tns v+passp pp+agby) '(lambda (aux%be+tns v+passp pp+agby) `(lambda (subj) (append (funcall ,aux%be+tns (funcall ,v+passp ',pp+agby subj)) '(:type passive))))) ;;; Modifications for test sentence 10: (add-rule-sem '(np+wh ==> pronp+wh) 'identity) (add-rule-sem '(q+wh ==> np+wh vp) '(lambda (np+wh vp) (wh-question np+wh (funcall vp np+wh)))) ;;; Modifications for test sentence 11: (add-rule-sem '(q+wh ==> np+wh q/np) '(lambda (np+wh q/np) (wh-question np+wh (funcall q/np np+wh)))) (add-rule-sem '(q/np ==> aux%do%modal np vbar-tns/np) '(lambda (aux%do%modal np vbar-tns/np) `(lambda (patient/beneficiary) (append (funcall ,vbar-tns/np ',np patient/beneficiary) '(:tense past))))) (add-rule-sem '(vbar-tns/np ==> v2-tns np/np) '(lambda (v2-tns np/np) v2-tns)) ;;; Modifications for test sentence 15: (add-rule-sem '(vbar-tns/np ==> v3-tns np pp+dat/np) '(lambda (v3-tns np pp+dat/np) `(lambda (subj beneficiary) (funcall ,v3-tns subj beneficiary ',np)))) (add-rule-sem '(pp+dat/np ==> p np/np) '(lambda (p np/np))) ;;; Modifications for test sentence 16: (add-rule-sem '(vbar-tns/np ==> v3-tns np/np pp+dat) '(lambda (v3-tns np/np pp+dat) `(lambda (subj patient) (funcall ,v3-tns subj ',pp+dat patient)))) ;;;==================================================================== ; -*- mode: lisp; package: (gpsg lisp); base: 10; syntax: common-lisp -*- ;in-package before provide is the wrong order according to guy steele, but ;otherwise lucid gives load warnings, so... ; (defpackage 'gpsg :use '(lisp)) (provide 'semantics) (eval-when (compile) (error "you're not supposed to compile this file!")) (require 'earley "/mit/6.863/semantics/earley.lisp") ;#+ibm "/mit/6.863/earley/parser" ; #+vax "/mit/6.863/earley/parser" ; #+:coral "6.863;earley:parser") (require 'match-allowing-extras "/mit/6.863/semantics/match-allowing-extras.lisp") ; #+vax "/mit/6.863/semantics/match-allowing-extras" ; #+:coral "6.863;semantics:match-allowing-extras") (require 'interpreter "/mit/6.863/semantics/interpreter.lisp") ;#+vax "/mit/6.863/semantics/interpreter" ; #+:coral "6.863;semantics:interpreter") (defvar *semantics-files* '("interpreter" "match-allowing-extras")) ;logical pathname 6.863 is defined in init-lisp (defvar *semantics-directory* "/mit/6.863/semantics/") ; #+vax "/mit/6.863/semantics/" ; #+:coral "6.863;semantics:") (defun compile-semantics () (mapc #'(lambda (file) (let ((file-with-dir (concatenate 'string *semantics-directory* file))) (format t "~%compiling ~a..." file-with-dir) (compile-file file-with-dir) ;; (load file-with-dir) )) *semantics-files*) (format t "~%compilation successful~%")) (verbose) ;(defun init-syntax () ; (declare (special *syntax-lexicon*)) ;(declare (special *syntax-grammar*)) ;(declare (special *syntax-cfg*)) ;(declare (special *rule-semantics-file*)) ;(declare (special *word-semantics-file*)) ;(remove-rule-set *syntax-lexicon*) ;(remove-rule-set *syntax-grammar*) ;(add-rule-set *syntax-lexicon* 'dictionary) ;(add-rule-set *syntax-grammar* 'cfg) ;(load *rule-semantics-file*) ;(load *word-semantics-file*) ;(remove-rule-set *syntax-cfg*) ;(create-cfg-table *syntax-cfg* *syntax-grammar* 'root 1) ;(p "john saw mary" :grammar *syntax-cfg* :dictionary *syntax-lexicon*)) (setf *word-semantics-file* "~/courses/nlp/lab5/new-words.lisp") (setf *rule-semantics-file* "~/courses/nlp/lab5/new-rules.lisp") (load "lab5-sentences") (init-syntax) (test-semantics) 1. sentence: "john gave mary fido" syntax: ((root (s (np (np-pro (name john))) (vp (v+args (v3+tns gave) (np (np-pro (name mary))) (np (np-pro (name fido)))))))) semantics: (give :agent john :patient fido :beneficiary mary :tense past) ok. semantics: nil 2. sentence: "john gave fido to mary" syntax: ((root (s (np (np-pro (name john))) (vp (v+args (v3+tns gave) (np (np-pro (name fido))) (pp+dat (p to) (np (np-pro (name mary))))))))) semantics: (give :agent john :patient fido :beneficiary mary :tense past) ok. semantics: nil 3. sentence: "did john give fido to mary" syntax: ((root (q-wh (aux%do%modal (aux%do+tns did)) (np (np-pro (name john))) (vbar-tns (v3-tns give) (np (np-pro (name fido))) (pp+dat (p to) (np (np-pro (name mary)))))))) semantics: yes/no-question (give :agent john :patient fido :beneficiary mary :tense past) yes. semantics: nil 4. sentence: "did john give mary fido" syntax: ((root (q-wh (aux%do%modal (aux%do+tns did)) (np (np-pro (name john))) (vbar-tns (v3-tns give) (np (np-pro (name mary))) (np (np-pro (name fido))))))) semantics: yes/no-question (give :agent john :patient fido :beneficiary mary :tense past) yes. semantics: nil 5. sentence: "mary kissed john" syntax: ((root (s (np (np-pro (name mary))) (vp (v+args (v2+tns kissed) (np (np-pro (name john)))))))) semantics: (kiss :agent mary :patient john :tense past) ok. semantics: nil 6. sentence: "fido was kissed" syntax: ((root (s (np (np-pro (name fido))) (vp (aux%be+tns was) (v+passp (v2+passp kissed)))))) semantics: (kiss :agent somebody :patient fido :tense past :type passive) ok. semantics: nil 7. sentence: "john was kissed by mary" syntax: ((root (s (np (np-pro (name john))) (vp (aux%be+tns was) (v+passp (v2+passp kissed)) (pp+agby (p by) (np (np-pro (name mary)))))))) semantics: (kiss :agent mary :patient john :tense past :type passive) ok. semantics: nil 8. sentence: "john saw fido" syntax: ((root (s (np (np-pro (name john))) (vp (v+args (v2+tns saw) (np (np-pro (name fido)))))))) semantics: (see :agent john :patient fido :tense past) ok. semantics: nil 9. sentence: "john saw mary" syntax: ((root (s (np (np-pro (name john))) (vp (v+args (v2+tns saw) (np (np-pro (name mary)))))))) semantics: (see :agent john :patient mary :tense past) ok. semantics: nil 10. sentence: "who saw fido" syntax: ((root (q+wh (np+wh (pronp+wh who)) (vp (v+args (v2+tns saw) (np (np-pro (name fido)))))))) semantics: wh-question ?who (see :agent ?who :patient fido :tense past) john answer semantics: (john) semantics: nil 11. sentence: "who did john see" syntax: ((root (q+wh (np+wh (pronp+wh who)) (q/np (aux%do%modal (aux%do+tns did)) (np (np-pro (name john))) (vbar-tns/np (v2-tns see) (np/np)))))) semantics: wh-question ?who (see :agent john :patient ?who :tense past) mary and fido answer semantics: (mary fido) semantics: nil 12. sentence: "who gave mary fido" syntax: ((root (q+wh (np+wh (pronp+wh who)) (vp (v+args (v3+tns gave) (np (np-pro (name mary))) (np (np-pro (name fido)))))))) semantics: wh-question ?who (give :agent ?who :patient fido :beneficiary mary :tense past) john answer semantics: (john) semantics: nil 13. sentence: "who gave john fido" syntax: ((root (q+wh (np+wh (pronp+wh who)) (vp (v+args (v3+tns gave) (np (np-pro (name john))) (np (np-pro (name fido)))))))) semantics: wh-question ?who (give :agent ?who :patient fido :beneficiary john :tense past) i don't know. semantics: nil 14. sentence: "who gave fido to mary" syntax: ((root (q+wh (np+wh (pronp+wh who)) (vp (v+args (v3+tns gave) (np (np-pro (name fido))) (pp+dat (p to) (np (np-pro (name mary))))))))) semantics: wh-question ?who (give :agent ?who :patient fido :beneficiary mary :tense past) john answer semantics: (john) semantics: nil 15. sentence: "who did john give fido to" syntax: ((root (q+wh (np+wh (pronp+wh who)) (q/np (aux%do%modal (aux%do+tns did)) (np (np-pro (name john))) (vbar-tns/np (v3-tns give) (np (np-pro (name fido))) (pp+dat/np (p to) (np/np))))))) semantics: wh-question ?who (give :agent john :patient fido :beneficiary ?who :tense past) mary answer semantics: (mary) semantics: nil 16. sentence: "who did john give to mary" syntax: ((root (q+wh (np+wh (pronp+wh who)) (q/np (aux%do%modal (aux%do+tns did)) (np (np-pro (name john))) (vbar-tns/np (v3-tns give) (np/np) (pp+dat (p to) (np (np-pro (name mary))))))))) semantics: wh-question ?who (give :agent john :patient ?who :beneficiary mary :tense past) fido answer semantics: (fido) semantics: nil 17. sentence: "who kissed fido" syntax: ((root (q+wh (np+wh (pronp+wh who)) (vp (v+args (v2+tns kissed) (np (np-pro (name fido)))))))) semantics: wh-question ?who (kiss :agent ?who :patient fido :tense past) somebody answer semantics: (somebody) semantics: nil 18. sentence: "who did mary kiss" syntax: ((root (q+wh (np+wh (pronp+wh who)) (q/np (aux%do%modal (aux%do+tns did)) (np (np-pro (name mary))) (vbar-tns/np (v2-tns kiss) (np/np)))))) semantics: wh-question ?who (kiss :agent mary :patient ?who :tense past) john answer semantics: (john) semantics: nil 19. sentence: "who was kissed by mary" syntax: ((root (q+wh (np+wh (pronp+wh who)) (vp (aux%be+tns was) (v+passp (v2+passp kissed)) (pp+agby (p by) (np (np-pro (name mary)))))))) semantics: wh-question ?who (kiss :agent mary :patient ?who :tense past :type passive) john answer semantics: (john) semantics: nil 20. sentence: "did somebody kiss fido" syntax: ((root (q-wh (aux%do%modal (aux%do+tns did)) (np (np-pro (name somebody))) (vbar-tns (v2-tns kiss) (np (np-pro (name fido))))))) semantics: yes/no-question (kiss :agent somebody :patient fido :tense past) yes. semantics: nil