Presentation is loading. Please wait.

Presentation is loading. Please wait.

LING 388 Language and Computers Lecture 13 10/14/03 Sandiway FONG.

Similar presentations


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

1 LING 388 Language and Computers Lecture 13 10/14/03 Sandiway FONG

2 Administrivia Next Class Next Class  … back in Franklin 210 Homework Assignment 3 Homework Assignment 3  Exercises 1 and 2 last lecture  Exercises 3, 4 and 5 today  Due date is next Tuesday  Submit all five exercises together to Charles (clin@u.arizona.edu)  (Option) Along with extra credit question from Lecture 11

3 Grammar From Exercises 1 and 2 … Example grammar so far has been augmented with: Example grammar so far has been augmented with:  Parse structure  Determiner/Noun number agreement DCG rules: DCG rules:  s(s(X,Y)) --> np(X), vp(Y).  np(np(X,Y)) --> det(X,Num), common_noun(Y,Num).  np(np(X)) --> proper_noun(X).  common_noun(n(man),sg) --> [man]. common_noun(n(men),sg) --> [men].  proper_noun(john) --> [john].  det(det(the),_) --> [the]. det(det(a),sg) --> [a].  vp(vp(X)) --> intransitive_verb(X).  vp(vp(X,Y)) --> transitive_verb(X), np(Y).  intransitive_verb(v(ran)) --> [ran].transitive_verb(v(saw)) --> [saw].

4 Exercise 3: Count and Mass Nouns To parse : To parse :  John likes beer  Note: beer can be a mass noun and does not need a determinerbeer can be a mass noun and does not need a determiner We need a rule for mass nouns: We need a rule for mass nouns:  np(np(X)) --> mass_noun(X).  Note: beer can also be a count nounbeer can also be a count noun Implement beer as both a count and mass noun Implement beer as both a count and mass noun Run Prolog Queries for: Run Prolog Queries for:  John likes a beer  John likes beer

5 Exercise 4: Logical Forms as Parses Pseudo-Logical Forms Pseudo-Logical Forms  From Exercise 1 …  We can see that we have a lot of freedom in deciding what gets returned as a parse kick the bucket => vp(v(die))kick the bucket => vp(v(die))  In the case of natural language quantifiers, we may wish to construct corresponding pseudo-logical forms as parses  Examples: Every man likes JohnEvery man likes John forall x, man(x), x likes Johnforall x, man(x), x likes John Some men like beerSome men like beer exists x, man(x), x likes beerexists x, man(x), x likes beer

6 Exercise 4: Logical Forms as Parses Homework Question Homework Question  (A) Modify your grammar to incorporate the corresponding pseudo-logical forms (exists and forall) for quantifiers some and every  Example: Every man likes JohnEvery man likes John forall x, man(x), x likes Johnforall x, man(x), x likes John  Instead of: s(np(q(every),n(man)),vp(v(likes),np(john)))s(np(q(every),n(man)),vp(v(likes),np(john)))  return: s(forall(X,man(X)),vp(v(likes),np(john))))s(forall(X,man(X)),vp(v(likes),np(john))))  Note: Ignoring Quantifier Raising (QR) for this exercise …

7 Exercise 4: Logical Forms as Parses Homework Question (A) contd. Homework Question (A) contd.  Your parser should also handle:  Some men like beer  exists x, man(x), x likes beer  Want to be able to substitute the fragment: … exists(X,men(X)) …… exists(X,men(X)) …for … np(q(some),n(men)) …… np(q(some),n(men)) …giving s(exists(X,men(X)),vp(v(like),np(n(beer))))s(exists(X,men(X)),vp(v(like),np(n(beer))))

8 Exercise 4: Logical Forms as Parses Homework Question (A) contd. Homework Question (A) contd.  Every man can be parsed using rules:  np(np(Y,Z)) --> quantifier(Y), common_noun(Z).  quantifier(q(every)) --> [every].  Problem Reduces To:  How to synthesize forall(M,man(M)) instead of np(Y,Z) ?  Don’t want to write:  np(forall(M,man(M))) --> quantifier(Y), common_noun(Z). … common noun may not be n(man)  Can’t write the rule:  np(forall(M,Z(M))) --> quantifier(Y), common_noun(Z). … because functors can’t be variables in Prolog

9 Exercise 4: Logical Forms as Parses What can we do? What can we do?  To solve this …  Need the ability to construct a structure p(X) (e.g. man(X)) taking one argument X and p (man) as its functor given a simple name p (e.g. man)  Example:  man => man(X)  np(q(every),n(man)) => forall(X,man(X)) … we’re going to need the Prolog built-in =.. known as “univ”

10 Univ (=..) The Prolog built-in predicate =.. The Prolog built-in predicate =..  =.. is known as the univ predicate  =.. is an infix predicate that takes two arguments  X =.. Y  X is a structure (or name)  Y is a list 1st element of Y is the functor of X1st element of Y is the functor of X Remaining elements of Y are the arguments of XRemaining elements of Y are the arguments of X  =.. is bi-directional  i.e. either X or Y (not both) can be variables

11 Univ (=..) Examples: Examples:  ?- man(X) =.. [man,X].  ?- the =.. [the].  ? - s(np(john),vp(v(ran))) =.. [s,np(john),vp(v(ran))]. Note: =.. “unpacks” a structure only one level down =.. “unpacks” a structure only one level down  ?- vp(v(ran)) =.. X. X = [vp,v(ran)]  ?- X =.. [the,man].X = the(man)  ?- X =.. Yis an error

12 Exercise 4: Logical Forms as Parses Summarizing… Summarizing…  Modify rule for NP -> Quantifier, N  Use =.. to construct the quantified expression Your modified grammar should produce the following parses: Your modified grammar should produce the following parses:  Every man likes John  s(forall(X,man(X)),vp(v(likes),np(john))))  Some men like beer  s(exists(X,men(X)),vp(v(like),np(n(beer)))) It should reject It should reject  *Every man like John/*Every men likes John/*Every men like John  *Some men likes beer/*Some man like beer/*Some man likes beer

13 Exercise 4: Logical Forms as Parses Homework Question (A) contd. Homework Question (A) contd.  Hint:  Use { … } to insert a call to =..  Note:  We have seen { … } before Recall Lecture 10Recall Lecture 10 –s --> [a],t(1),[c]. –t(N) --> [a],{M is N+1},t(M),[c]. –t(N) --> u(N). –u(N) --> [b],{M is N-1},u(M). –u(1) --> [b].

14 Exercise 4: Logical Forms as Parses Homework Question (B) Homework Question (B)  Generic interpretation for bare plurals  Example: The men drink beerThe men drink beer Men drink beerMen drink beer forall x, men(x), x drink beerforall x, men(x), x drink beer … as a first approximation  Write a DCG rule for interpreting bare plurals as universally quantified nouns

15 Exercise 4: Logical Forms as Parses Homework Question (B) contd. Homework Question (B) contd.  Make sure your grammar produces: s(forall(X,men(X)),vp(v(drink),np(n(beer))))s(forall(X,men(X)),vp(v(drink),np(n(beer)))) for the Prolog query: ?- s(X,[men,drink,beer],[]).?- s(X,[men,drink,beer],[]).

16 Exercise 5: More Agreement Exercise 2 (last time): Exercise 2 (last time):  … showed how to enforce agreement between two constituents in a single DCG rule:  np(np(X,Y)) --> det(X,Num), common_noun(Y,Num). Solution depends on fact: Solution depends on fact:  Scope of Prolog variable Num is the entire clause np X[Num]Y[Num]

17 Exercise 5: More Agreement Question: Question:  What do when we want to apply agreement when constituents are not from a single DCG rule? Example: Example:  Subject-Verb agreement  John likes the man/*John like the man  I like the man/*I likes the man  Every man likes John/ *every man like John  Some men like beer/*some men likes beer  Subject and verb need to agree in person and number features

18 Exercise 5: More Agreement But subject-verb agreement can’t be localized in a single DCG rule But subject-verb agreement can’t be localized in a single DCG rule Example Parse: Example Parse: s np vp v np detn theman likes [3,sg] John [3,sg]

19 Exercise 5: More Agreement Lexicon: Lexicon:  proper_noun(john) --> [john].  transitive_verb(v(likes)) --> [likes]. Affected phrase structure rules: Affected phrase structure rules:  s(s(X,Y)) --> np(X), vp(Y).  vp(vp(X)) --> intransitive_verb(X).  vp(vp(X,Y)) --> transitive_verb(X), np(Y).

20 Exercise 5: More Agreement Basic Idea: Basic Idea:  Pass relevant agreement features as variables through intermediate nodes s np vp v np detn theman likes [3,sg] John [3,sg]

21 Exercise 5: More Agreement Modify existing DCG rules to include variables and values for agreement features person and number Modify existing DCG rules to include variables and values for agreement features person and number Step 1: Add features to lexical rules: Step 1: Add features to lexical rules:  proper_noun(john,3,sg) --> [john].  transitive_verb(v(likes),3,sg) --> [likes]. Question: Question:  What to do with P and N for  transitive_verb(v(like),P,N) --> [like].  Like agrees with anything that’s not 3rd person singular … ignoring tense in this exercise Solution: Solution:  Recall we can call Prolog code from within DCG rules …  transitive_verb(v(like),P,N) --> [like], { \+ ( P=3, N=sg) }. … this only works if P and N are valued before tests are executed

22 Exercise 5: More Agreement Prolog Parse Order (In-Order Tree Traversal): Prolog Parse Order (In-Order Tree Traversal):  Subject NP is parsed before VP => P and N are valued before unifying with V s np vp v np detn theman likes [3,sg] John [3,sg] 1 2 3 4 5

23 Exercise 5: More Agreement Step 2: Pass person and number features through intermediate nodes Step 2: Pass person and number features through intermediate nodes  “Local” constituents:  s(s(X,Y)) --> np(X,P,N), vp(Y,P,N).  Intermediate nodes:  vp(vp(X),P,N) --> intransitive_verb(X,P,N).  vp(vp(X,Y),P,N) --> transitive_verb(X,P,N), np(Y,_,_).  Note:  All np rules need to be revised to take both P and N features

24 Exercise 5: More Agreement Homework Question: Homework Question:  Revise the DCG rules to accept the examples listed at the start of the exercise:  John likes the man/*John like the man  I like the man/*I likes the man  Every man likes John/ *every man like John  Some men like beer/*some men likes beer  Note:  You’ll need to write DCG rules for pronouns


Download ppt "LING 388 Language and Computers Lecture 13 10/14/03 Sandiway FONG."

Similar presentations


Ads by Google