Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "LING 388 Language and Computers Lecture 12 10/9/03 Sandiway FONG."— Presentation transcript:

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

2 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

3 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

4 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

5 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].

6 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))))

7 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],[]).

8 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

9 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

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

11 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)

12 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].

13 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

14 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


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

Similar presentations


Ads by Google