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

Slides:



Advertisements
Similar presentations
Prolog programming....Dr.Yasser Nada. Chapter 8 Parsing in Prolog Taif University Fall 2010 Dr. Yasser Ahmed nada prolog programming....Dr.Yasser Nada.
Advertisements

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.
CSA2050: DCG I1 CSA2050 Introduction to Computational Linguistics Lecture 8 Definite Clause Grammars.
LING 388: Language and Computers Sandiway Fong Lecture 5: 9/8.
LING/C SC/PSYC 438/538 Lecture 22 Sandiway Fong 1.
01/11/04 AIPP Lecture 11: Parsing and Semantics in DCGs1 Parsing and Semantics in DCGs Artificial Intelligence Programming in Prolog Lecturer: Tim Smith.
LING 364: Introduction to Formal Semantics Lecture 8 February 7th.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 7: 9/12.
LING 388 Language and Computers Lecture 2 9/04/03 Sandiway FONG.
LING 388 Language and Computers Lecture 19 11/04/03 Sandiway FONG.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 9: 9/21.
Parsing: Features & ATN & Prolog By
LING 388: Language and Computers Sandiway Fong Lecture 15: 10/17.
LING 388 Language and Computers Lecture 14 10/16/03 Sandiway FONG.
LING 388 Language and Computers Lecture 8 9/25/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 28: 12/6.
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 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 388: Language and Computers Sandiway Fong Lecture 28: 12/5.
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 364: Introduction to Formal Semantics Lecture 13 February 23rd.
LING 388 Language and Computers Lecture 16 10/23/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 16: 10/19.
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 12 10/9/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.
October 2004csa4050: Semantics II1 CSA4050: Advanced Topics in NLP Semantics II The Lambda Calculus Semantic Representation Encoding in Prolog.
1 Features and Unification Chapter 15 October 2012 Lecture #10.
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.
LING 388: Language and Computers Sandiway Fong Lecture 4.
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 30 12/8.
LING 388: Language and Computers Sandiway Fong Lecture 18.
1 Natural Language Processing Lecture Notes 11 Chapter 15 (part 1)
LING 388: Language and Computers Sandiway Fong Lecture 10.
LING 388: Language and Computers Sandiway Fong Lecture 19.
October 2004CSA4050: Semantics III1 CSA4050: Advanced Topics in NLP Semantics III Quantified Sentences.
LING 388: Language and Computers Sandiway Fong Lecture 13.
2007CLINT-LIN-FEATSTR1 Computational Linguistics for Linguists Feature Structures.
Semantic Construction lecture 2. Semantic Construction Is there a systematic way of constructing semantic representation from a sentence of English? This.
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.
◦ Process of describing the structure of phrases and sentences Chapter 8 - Phrases and sentences: grammar1.
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.
Syntax and Processing it: Definite Clause Grammars in Prolog (optional material) John Barnden School of Computer Science University of Birmingham Natural.
Natural Language Processing
LING/C SC/PSYC 438/538 Lecture 21 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 22 Sandiway Fong.
CSA4050: Advanced Topics in NLP
Presentation transcript:

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

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  (Option) Along with extra credit question from Lecture 11

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

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

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

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 …

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

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

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”

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

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

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

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

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

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

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]

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

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]

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

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]

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

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]

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

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