LING 388 Language and Computers Lecture 15 10/21/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.
Logic Programming – Part 2 Lists Backtracking Optimization (via the cut operator) Meta-Circular Interpreters.
Logic Programming – Part 2 Lists Backtracking Optimization (via the cut operator) Meta-Circular Interpreters.
LING 388: Language and Computers Sandiway Fong Lecture 5: 9/5.
CSA4050: Advanced Topics in NLP Semantics IV Partial Execution Proper Noun Adjective.
1 Programming Languages (CS 550) Lecture Summary Functional Programming and Operational Semantics for Scheme Jeremy R. Johnson.
LING 388: Language and Computers Sandiway Fong Lecture 9: 9/27.
LING 388: Language and Computers Sandiway Fong Lecture 15.
LING 581: Advanced Computational Linguistics Lecture Notes April 23rd.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 3: 8/29.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 7: 9/12.
LING 364: Introduction to Formal Semantics Lecture 10 February 14th.
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 388 Language and Computers Lecture 14 10/16/03 Sandiway FONG.
LING 388: Language and Computers Sandiway Fong Lecture 20: 11/2.
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 Sandiway Fong Lecture 4: 8/31.
LING 388: Language and Computers Sandiway Fong Lecture 11: 10/3.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 6: 9/7.
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 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 11 10/7/03 Sandiway FONG.
LING 388 Language and Computers Lecture 16 10/23/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 12 10/9/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.
October 2004csa4050: Semantics II1 CSA4050: Advanced Topics in NLP Semantics II The Lambda Calculus Semantic Representation Encoding in Prolog.
Logic Programming Lecture 6: Parsing, Difference Lists and Definite Clause Grammars.
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 7.
LING 388: Language and Computers Sandiway Fong Lecture 18.
LING 388: Language and Computers Sandiway Fong Lecture 10.
Formal Semantics Chapter Twenty-ThreeModern Programming Languages, 2nd ed.1.
October 2004CSA4050: Semantics III1 CSA4050: Advanced Topics in NLP Semantics III Quantified Sentences.
LING 388: Language and Computers Sandiway Fong Lecture 13.
LING/C SC/PSYC 438/538 Lecture 26 Sandiway Fong. Administrivia 538 Presentations – Send me your choices if you haven’t already Thanksgiving Holiday –
Semantic Construction lecture 2. Semantic Construction Is there a systematic way of constructing semantic representation from a sentence of English? This.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
LING 388: Language and Computers Sandiway Fong Lecture 12.
LING 388: Language and Computers Sandiway Fong Lecture 11: 10/4.
Albert Gatt LIN3021 Formal Semantics Lecture 4. In this lecture Compositionality in Natural Langauge revisited: The role of types The typed lambda calculus.
CSE 230 The -Calculus. Background Developed in 1930’s by Alonzo Church Studied in logic and computer science Test bed for procedural and functional PLs.
Rules, Movement, Ambiguity
Lecture on Set! And Local CS 2135 Copyright Kathi Fisler, 2002 This material requires Advanced Language Level.
CMSC 330: Organization of Programming Languages Operational Semantics.
LING/C SC/PSYC 438/538 Lecture 19 Sandiway Fong 1.
Natural Language Processing
September 4, 1997 Programming Languages (CS 550) Lecture 6 Summary Operational Semantics of Scheme using Substitution Jeremy R. Johnson TexPoint fonts.
LING/C SC/PSYC 438/538 Lecture 21 Sandiway Fong.
LING 581: Advanced Computational Linguistics
6.001 SICP Interpretation Parts of an interpreter
Presentation transcript:

LING 388 Language and Computers Lecture 15 10/21/03 Sandiway FONG

Administrivia Homework Assignment 3 Homework Assignment 3  Due today  Need help? Error in Lecture 10 slide for a n b n c n fixed … Error in Lecture 10 slide for a n b n c n fixed …  s --> [a],t(1),[c].  t(N) --> [a],{M is N+1},t(M),[c].  t(N) --> u(N).  u(N) --> {N>1}, [b],{M is N-1},u(M).  u(1) --> [b].

-Calculus Lambda ( ) calculus: Lambda ( ) calculus:  Concerned with the definition of anonymous functions and their application  Invented by Alonzo Church to explore computability of functions Example definition: Example definition:  x.x+3“is a function that adds 3 to x”  Note : we did not give this function a name - hence the term “anonymous”we did not give this function a name - hence the term “anonymous”

-Calculus Example of application: Example of application:   x.x+3) 2“apply lambda function to 2” (  -reduction)   x+3) [2/x]“substitute 2 for x”  2+3“evaluate function”  5 There is much more to -calculus There is much more to -calculus  But this is all we need …

Last Time … We looked at the parsing of empty NPs in relative clause constructions We looked at the parsing of empty NPs in relative clause constructions  Example:  the cat that I saw  the cat i that I saw [ NP e i ]  (the cat)( x.I saw x) By analogy:  that I saw [ NP e i ] has the semantics of x.I saw x  This function returns x

Last Time … The rule that generated the empty category [ NP e i ] allowed for considerable overgeneration The rule that generated the empty category [ NP e i ] allowed for considerable overgeneration  Examples:  *Hit the ball[ NP e i ] hit the ball  *John hitJohn hit [ NP e i ]  *Hit [ NP e i ] hit [ NP e i ]  … all of which can be accepted as complete sentences by the DCG

Last Time … To control the overgeneration, we needed some condition on representation … To control the overgeneration, we needed some condition on representation …  Filter:  All variables must be bound by an operator ( x)  Example:  *John hits(np(john),vp(v(hit),np(x))) Today’s Lecture: Today’s Lecture:  How to implement this filter

Condition on Representation Basic Idea: Basic Idea:  Scan phrase structure looking for a variable and operator  Succeed only if matching operator found Scan Operation: Scan Operation:  Tree-walker  Walk through a tree node-by-node, testing each node to see if we have found what we’re looking for

Condition on Representation Also make use of two elements that we’ve already seen: Also make use of two elements that we’ve already seen:  =.. (univ) man(X) =.. [man,X]  to deconstruct structures  Feature propagation  to send information up the tree s np vp v np detn theman likes [3,sg] John [3,sg] P,N

Tree-Walker Question: Question:  How to scan phrase structure tree? Answer: Answer:  Write a recursive predicate, a tree- walker, to visit every node of a tree

Tree-Walker Assuming phrase structure trees are binary branching at the most… Assuming phrase structure trees are binary branching at the most… Tree-Walker must deal with three cases: Tree-Walker must deal with three cases: A. Binary branching visit both subtrees B. Unary branching visit child subtree C. Terminal node done np detn theman vp ran v A B C

Tree-Walker Example Prolog code: Example Prolog code: Define a predicate visit/1 taking as its argument a phrase structure tree  visit(X) :- % Case A  X =.. [F,A1,A2],  visit(A1),  visit(A2).  visit(X) :-% Case B  X =.. [F,A],  visit(A).  visit(X) :-% Case C  atom(X).atom/1 built-in np detn theman vp ran v A B C X F=np A1 A2 X F=vp A

Tree-Walker visit/1 example: visit/1 example:  Inorder traversal s npvp vnp detn theman saw john

Tree-Walker visit/1 doesn’t really do anything yet visit/1 doesn’t really do anything yet  Need to add a specific test for np(x)  Example:  *John hits(np(john),vp(v(hit),np(x)))  visit(X) :-  X =.. [F,A1,A2],  visit(A1),  visit(A2).  visit(X) :-  X =.. [F,A],  visit(A).  visit(X) :- atom(X). visit(np(x)).

Tree-Walker We can write visit/1 to succeed only if it finds np(x) We can write visit/1 to succeed only if it finds np(x)  visit(np(x)).  visit(X) :-  X =.. [F,A1,A2],  visit(A1),  visit(A2).  visit(X) :-  X =.. [F,A],  visit(A).  visit(X) :- atom(X).  visit(np(x)).  visit(X) :-  X =.. [F,A1,A2],  visit(A1).  visit(X) :-  X =.. [F,A1,A2],  visit(A2).  visit(X) :-  X =.. [F,A],  visit(A). Succeeds always Succeeds only if np(x) exists

Tree-Walker New visit/1 example for *John hit [ NP e]: New visit/1 example for *John hit [ NP e]: s npvp vnp x hit john visit(X) succeeds visit(X) fails

Tree-Walker Call the first form a conjunctive tree-walker, the 2nd a disjunctive tree-walker Call the first form a conjunctive tree-walker, the 2nd a disjunctive tree-walker  visit(np(x)).  visit(X) :-  X =.. [F,A1,A2],  visit(A1),  visit(A2).  visit(X) :-  X =.. [F,A],  visit(A).  visit(X) :- atom(X).  visit(np(x)).  visit(X) :-  X =.. [F,A1,A2],  visit(A1).  visit(X) :-  X =.. [F,A1,A2],  visit(A2).  visit(X) :-  X =.. [F,A],  visit(A). Either visit A1 or A2 Visit A1 and A2

Tree-Walker Let’s rename our modified version of visit/1 to reflect the new semantics Let’s rename our modified version of visit/1 to reflect the new semantics  variable(np(x)).  variable(X) :-  X =.. [F,A1,A2],  variable(A1).  variable(X) :-  X =.. [F,A1,A2],  variable(A2).  variable(X) :-  X =.. [F,A],  variable(A). variable/1 holds only if there exists np(x) in the phrase structure variable/1 holds only if there exists np(x) in the phrase structure Examples: ?- variable(s(np(john),vp(v(hit),np(x)))).?- variable(s(np(john),vp(v(hit),np(x)))). YesYes ?- variable(s(np(john),vp(v(hit),np(mary)))).?- variable(s(np(john),vp(v(hit),np(mary)))). NoNo ?-variable ( np(np(det(the),n(cat)),?-variable ( np(np(det(the),n(cat)),lambda(x,s(np(i),vp(v(saw),np(x)))))). YesYes

Tree-Walker Let’s build another modified version of visit/1 that succeeds only if there exists an operator  x, i.e. lambda(x,_), in the phrase structure Let’s build another modified version of visit/1 that succeeds only if there exists an operator  x, i.e. lambda(x,_), in the phrase structure  operator(lambda(x,_)).  operator(X) :-  X =.. [F,A1,A2],  operator(A1).  operator(X) :-  X =.. [F,A1,A2],  operator(A2).  operator(X) :-  X =.. [F,A],  operator(A). Examples: ?- operator(s(np(john),vp(v(hit),np(x)))).?- operator(s(np(john),vp(v(hit),np(x)))). NoNo ?- operator(s(np(john),vp(v(hit),np(mary)))).?- operator(s(np(john),vp(v(hit),np(mary)))). NoNo ?-operator ( np(np(det(the),n(cat)),?-operator ( np(np(det(the),n(cat)),lambda(x,s(np(i),vp(v(saw),np(x)))))). YesYes

Filter Implementation Filter: Filter:  All variables must be bound by an operator ( x) Implementation (Initial try) : Implementation (Initial try) :  filter(X) :- variable(X), operator(X).  filter(X) :- \+ variable(X).  succeeds either when there is no variable in X or when a variable and an operator co-occur in X Use : Use :  ?- s(X,Sentence,[]), filter(X).  X is the phrase structure returned by the DCG  Sentence is the input sentence encoded as a list  filter/1 is a condition on representation

Filter Implementation Filter: Filter:  All variables must be bound by an operator ( x) Implementation : Implementation :  filter(X) :- variable(X), operator(X).  filter(X) :- \+ variable(X). Description: Description:  filter(X) succeeds either when there is no variable in X or when a variable and an operator co-occur in X

Filter Implementation A simpler rendering of filter/1 : A simpler rendering of filter/1 :  filter(X) :- variable(X) -> operator(X) ; true.  Advantage: one clause implementation instead of two … Note: Note:  -> is the “then” operator in Prolog  compare with the DCG operator -->  Semantics:  X -> Y ; Z if X is true then Y must be true if X is not true, Z must be true if X is not true, Z must be true

Filter Implementation Note: Note:  filter(X) :- variable(X) -> operator(X) ; true. is only a first approximation implementation of  All variables must be bound by an operator ( x)  Example:  *the cat that I saw hit  s(np(np(det(the),n(cat)),lambda(x,s(np(i),vp(v(saw),np(x))))), vp(v(hit),np(x))) vp(v(hit),np(x))) filter/1 (incorrectly) holds for the above example because:  filter/1 looks only for one variable, and  filter/1 looks for an operator anywhere in the phrase structure