LING 388 Language and Computers Lecture 12 10/9/03 Sandiway FONG.

Slides:



Advertisements
Similar presentations
Review of Homework 4 November 20, Exercise 1 (A) 1 pt Modify the DCG to accept the omission of the complementizer that for object relative clauses.
Advertisements

November 2008NLP1 Natural Language Processing Definite Clause Grammars.
LING 364: Introduction to Formal Semantics Lecture 24 April 13th.
LING 388: Language and Computers Sandiway Fong Lecture 28 12/1.
DEFINITE CLAUSE GRAMMARS Ivan Bratko University of Ljubljana Faculty of Computer and Information Sc.
01/11/04 AIPP Lecture 11: Parsing and Semantics in DCGs1 Parsing and Semantics in DCGs Artificial Intelligence Programming in Prolog Lecturer: Tim Smith.
For Monday Read Chapter 23, sections 3-4 Homework –Chapter 23, exercises 1, 6, 14, 19 –Do them in order. Do NOT read ahead.
LING 388: Language and Computers Sandiway Fong Lecture 16: 10/20.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 7: 9/12.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 10: 9/27.
LING 388 Language and Computers Lecture 2 9/04/03 Sandiway FONG.
LING 364: Introduction to Formal Semantics Lecture 9 February 9th.
LING 388 Language and Computers Lecture 19 11/04/03 Sandiway FONG.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 9: 9/21.
LING 388: Language and Computers Sandiway Fong Lecture 15: 10/17.
LING 364: Introduction to Formal Semantics
LING 388 Language and Computers Lecture 14 10/16/03 Sandiway FONG.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 7: 9/11.
LING 388 Language and Computers Lecture 8 9/25/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 28: 12/6.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 22: 11/15.
LING 388: Language and Computers Sandiway Fong Lecture 20: 11/2.
LING 364: Introduction to Formal Semantics Lecture 4 January 24th.
LING 388: Language and Computers Sandiway Fong Lecture 14: 10/13.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 9: 9/25.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 6: 9/6.
LING 388: Language and Computers Sandiway Fong Lecture 6: 9/13.
LING 388 Language and Computers Lecture 10 10/2/03 Sandiway FONG.
LING 388 Language and Computers Take-Home Final Examination 12/9/03 Sandiway FONG.
LING 364: Introduction to Formal Semantics Lecture 7 February 2nd.
LING 388 Language and Computers Lecture 20 11/6/03 Sandiway FONG.
LING 388 Language and Computers Lecture 18 10/30/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 17: 10/25.
LING 388 Language and Computers Lecture 16 10/23/03 Sandiway FONG.
LING 388 Language and Computers Lecture 7 9/23/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 16: 10/19.
LING 388 Language and Computers Lecture 9 9/30/03 Sandiway FONG.
LING 388 Language and Computers Lecture 13 10/14/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 17: 10/24.
LING 364: Introduction to Formal Semantics Lecture 5 January 26th.
LING 388 Language and Computers Lecture 17 10/28/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 13: 10/10.
LING 388 Language and Computers Lecture 6 9/18/03 Sandiway FONG.
LING 388 Language and Computers Lecture 15 10/21/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 8.
LING 388: Language and Computers Sandiway Fong 10/4 Lecture 12.
LING/C SC/PSYC 438/538 Lecture 19 Sandiway Fong 1.
LING 388: Language and Computers Sandiway Fong Lecture 11.
LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.
LING 388: Language and Computers Sandiway Fong Lecture 17.
LING 388: Language and Computers Sandiway Fong Lecture 27.
For Friday Finish chapter 23 Homework: –Chapter 22, exercise 9.
LING 388: Language and Computers Sandiway Fong Lecture 7.
LING/C SC/PSYC 438/538 Lecture 14 Sandiway Fong. Administrivia Midterm – This Wednesday – A bit like doing a homework in real time – Bring your laptop.
LING 388: Language and Computers Sandiway Fong Lecture 15 10/13.
LING 388: Language and Computers Sandiway Fong Lecture 3.
LING 388: Language and Computers Sandiway Fong Lecture 18.
LING 388: Language and Computers Sandiway Fong Lecture 10.
LING 388: Language and Computers Sandiway Fong Lecture 19.
LING 388: Language and Computers Sandiway Fong Lecture 13.
For Wednesday Read chapter 23 Homework: –Chapter 22, exercises 1,4, 7, and 14.
LING 388: Language and Computers Sandiway Fong Lecture 12.
LING 388: Language and Computers Sandiway Fong Lecture 11: 10/4.
LING 388: Language and Computers Sandiway Fong Lecture 21.
LING/C SC/PSYC 438/538 Lecture 20 Sandiway Fong 1.
LING 388: Language and Computers Sandiway Fong Lecture 16.
LING 388: Language and Computers Sandiway Fong Lecture 20.
LING/C SC/PSYC 438/538 Lecture 19 Sandiway Fong 1.
LING/C SC/PSYC 438/538 Lecture 21 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 22 Sandiway Fong.
Presentation transcript:

LING 388 Language and Computers Lecture 12 10/9/03 Sandiway FONG

Administrivia Computer Lab Today Computer Lab Today  … class will continue next Tuesday (14th)  Location: SBS 224 Homework Assignment 3 Homework Assignment 3  1st half of the exercises will be presented today  2nd half next Tuesday  Combined due date is the following Tuesday (21st)  Submit both halves together to Charles  (Optional) Along with extra credit question from Lecture 11

Today’s Theme Natural Language Parsing with Definite Clause Grammars (DCG) Natural Language Parsing with Definite Clause Grammars (DCG) s npvp vnp detn theball hit i

Exercise 1: Recovery of Phrase Structure From Lecture 10 … From Lecture 10 …  we know we can build phrase structure compositionally by adding a parameter for the non-terminals in each DCG rule Example: Example:  s --> np, vp. =>  s(X) --> np(Y), vp(Z). =>  s(s(Y,Z)) --> np(Y), vp(Z). s …… X = s YZ

Exercise 1: Recovery of Phrase Structure Convert example acceptor below into a parser: Convert example acceptor below into a parser:  s --> np, vp.  np --> det, common_noun.  np --> proper_noun.  common_noun --> [man].  proper_noun --> [john].  det --> [the].  vp --> intransitive_verb.  vp --> transitive_verb, np.  intransitive_verb --> [ran].  transitive_verb --> [saw].

Exercise 1: Recovery of Phrase Structure Make sure your parser produce structures encoding the following parses: Make sure your parser produce structures encoding the following parses: s npvp vnp detn theman saw john s npvp v ran john s(np(john),vp(v(ran))) s(np(john),vp(v(saw),np(det(the), n(man))))

Exercise 1: Recovery of Phrase Structure SWI-Prolog Convention: SWI-Prolog Convention:  Recall that the extra parameter gets added as the first argument of the Prolog clauses representing the DCG rules Run Prolog Queries: Run Prolog Queries:  ?- s(X,[john,ran],[]).  ?- s(X,[john,saw,the,man],[]).  ?- s(X,[john,ran,the,man],[]).

Exercise 1: Recovery of Phrase Structure Homework Question Homework Question  (A) Add the DCG rules necessary to encode the literal meaning of John kicked the bucket, i.e. s npvp vnp det n thebucket kicked john

Exercise 1: Recovery of Phrase Structure Homework Question Homework Question  (B) Add a DCG rule to encode the idiomatic meaning of John kicked the bucket, i.e. s npvp v died john ?- s(X,[john,kicked,the,bucket],[]) X = s(np(john),vp(v(died)))  Note: confirm that your parser returns both the literal and idiomatic parses  Hint: see how the terminal string the ball was encoded in Lecture 10

Exercise 2: Agreement Constraints Extra Parameter: Extra Parameter:  We can also use an extra parameter to impose constraints between constituents within a DCG rule Example: Example:  Number Agreement  DCG rule: np --> det, common_noun.np --> det, common_noun.  Data: the man/menthe man/men a man/*mena man/*men

Exercise 2: Agreement Constraints Augmenting the DCG rule … Augmenting the DCG rule … np --> det, common_noun.np --> det, common_noun.=> np(np(D,N)) --> det(D), common_noun(N).np(np(D,N)) --> det(D), common_noun(N).=> np(np(D,N)) --> det(D,Num), common_noun(N,Num).np(np(D,N)) --> det(D,Num), common_noun(N,Num).  Notes:  Num is a variable to be bound to a value from the set {sg,pl} (sg = singular, pl = plural)(sg = singular, pl = plural)  Non-terminals det and common_noun now take two extra parameters (instead of one)

Exercise 2: Agreement Constraints Consequently … Consequently …  accompanying definitions for det and common_noun must all take two extra parameters  For det: det(det(the),_) --> [the].det(det(the),_) --> [the]. –i.e. the can match with any number det(det(a),sg) --> [a].det(det(a),sg) --> [a]. –i.e. a has a number feature with value sg  Similarly, for common_noun: common_noun(n(man),sg) --> [man].common_noun(n(man),sg) --> [man]. common_noun(n(men),pl) --> [men].common_noun(n(men),pl) --> [men].

Exercise 2: Agreement Constraints Add the number constraint to your DCG grammar Add the number constraint to your DCG grammar Verify your implementation works correctly by running Prolog Queries for the following examples: Verify your implementation works correctly by running Prolog Queries for the following examples:  John saw the men  John saw the man  A man saw John  *A men saw John

Exercise 2: Agreement Constraints Homework Question Homework Question  Modify your grammar to handle quantifiers some and every  Data: Some men like JohnSome men like John Some man likes JohnSome man likes John Every man likes JohnEvery man likes John *Every men like John*Every men like John  Return the appropriate parse trees  Note: You’ll need to add DCG rules for verb forms like and likesYou’ll need to add DCG rules for verb forms like and likes –Don’t worry about subject/verb agreement for this exercise –We’ll return to consider this next Tuesday