November 2008NLP1 Natural Language Processing Definite Clause Grammars.

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

October 2004CSA4050: Semantics III1 CSA4050: Advanced Topics in NLP Semantics III Quantified Sentences.
 Christel Kemke 2007/08 COMP 4060 Natural Language Processing Feature Structures and Unification.
Natural Language Processing Lecture 2: Semantics.
CSA2050: DCG I1 CSA2050 Introduction to Computational Linguistics Lecture 8 Definite Clause Grammars.
© Patrick Blackburn, Johan Bos & Kristina Striegnitz Lecture 6: More Lists Theory –Define append/3, a predicate for concatenating two lists, and illustrate.
Prolog: List © Patrick Blackburn, Johan Bos & Kristina Striegnitz.
Cs7120 (Prasad)L21-DCG1 Definite Clause Grammars
CSA4050: Advanced Topics in NLP Semantics IV Partial Execution Proper Noun Adjective.
Syntax. Definition: a set of rules that govern how words are combined to form longer strings of meaning meaning like sentences.
CSA2050: DCG IV1 CSA2050: Definite Clause Grammars IV Handling Gaps II Semantic Issues.
Feb MRDefinite Clause Grammar1 An Introduction to Definite Clause Grammars Grammars and Algorithms Prolog Recogniser DCGs.
Grammatical Relations and Lexical Functional Grammar Grammar Formalisms Spring Term 2004.
DEFINITE CLAUSE GRAMMARS Ivan Bratko University of Ljubljana Faculty of Computer and Information Sc.
Natural Language Processing DCG and Syntax NLP DCG A “translation” example: special case A DCG recogniser.
For Monday Read Chapter 23, sections 3-4 Homework –Chapter 23, exercises 1, 6, 14, 19 –Do them in order. Do NOT read ahead.
Natural Language Processing - Feature Structures - Feature Structures and Unification.
NLP and Speech Course Review. Morphological Analyzer Lexicon Part-of-Speech (POS) Tagging Grammar Rules Parser thethe – determiner Det NP → Det.
© Patrick Blackburn, Johan Bos & Kristina Striegnitz Lecture 8: More DCGs Theory –Examine two important capabilities offered by DCG notation: Extra arguments.
LING 388: Language and Computers Sandiway Fong Lecture 15: 10/17.
LING 364: Introduction to Formal Semantics
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 9: 9/25.
© Patrick Blackburn, Johan Bos & Kristina Striegnitz Lecture 7: Definite Clause Grammars Theory –Introduce context free grammars and some related concepts.
 Christel Kemke 2007/08 COMP 4060 Natural Language Processing Feature Structures and Unification.
Features and Unification
© Patrick Blackburn, Johan Bos & Kristina Striegnitz Lecture 7: Definite Clause Grammars Theory –Introduce context free grammars and some related concepts.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 6: 9/7.
LING 388 Language and Computers Take-Home Final Examination 12/9/03 Sandiway FONG.
1/17 Probabilistic Parsing … and some other approaches.
1 Introduction: syntax and semantics Syntax: a formal description of the structure of programs in a given language. Semantics: a formal description of.
Natural Language Processing
Features and Unification Read J & M Chapter 11.. Solving the Agreement Problem Number agreement: S  NP VP * Mary walk. [NP NUMBER] [VP NUMBER] NP  det.
LING 364: Introduction to Formal Semantics Lecture 5 January 26th.
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 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.
LING 388: Language and Computers Sandiway Fong Lecture 17.
For Friday Finish chapter 23 Homework: –Chapter 22, exercise 9.
LING 388: Language and Computers Sandiway Fong Lecture 7.
Programming Languages The Beginning. In the beginning... Computers were very expensive; programmers were cheap Programming was by plugboards or binary.
November 2003CSA4050: Semantics I1 CSA4050: Advanced Topics in NLP Semantics I What is semantics for? Role of FOL Montague Approach.
May 2006CLINT-LN Parsing1 Computational Linguistics Introduction Parsing with Context Free Grammars.
PS: Introduction to Psycholinguistics Winter Term 2005/06 Instructor: Daniel Wiechmann Office hours: Mon 2-3 pm Phone:
October 2004CSA4050: Semantics III1 CSA4050: Advanced Topics in NLP Semantics III Quantified Sentences.
Parsing. Language A set of strings from an alphabet which may be empty, finite or infinite. A language is defined by a grammar and we may also say that.
For Wednesday Read chapter 23 Homework: –Chapter 22, exercises 1,4, 7, and 14.
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 11: 10/4.
1 Definite Clause Grammars for Language Analysis – A Survey of the Formalism and a Comparison with Augmented Transition Networks 인공지능 연구실 Hee keun Heo.
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
Rules, Movement, Ambiguity
NLP. Introduction to NLP Background –Developed by Jay Earley in 1970 –No need to convert the grammar to CNF –Left to right Complexity –Faster than O(n.
The Functions and Purposes of Translators Syntax (& Semantic) Analysis.
Section 11.3 Features structures in the Grammar ─ Jin Wang.
November 2004csa3050: Sentence Parsing II1 CSA350: NLP Algorithms Sentence Parsing 2 Top Down Bottom-Up Left Corner BUP Implementation in Prolog.
Computing Science, University of Aberdeen1 CS4025: Grammars l Grammars for English l Features l Definite Clause Grammars See J&M Chapter 9 in 1 st ed,
April 2010Semantic Grammar1 A short guide to Blackburn’s Grammar of English.
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 Vasile Rus
Comp 411 Principles of Programming Languages Lecture 3 Parsing
Natural Language Processing
LING/C SC/PSYC 438/538 Lecture 21 Sandiway Fong.
CSE322 LEFT & RIGHT LINEAR REGULAR GRAMMAR
LING/C SC/PSYC 438/538 Lecture 22 Sandiway Fong.
CSA4050: Advanced Topics in NLP
Lecture 7: Definite Clause Grammars
Artificial Intelligence 2004 Speech & Natural Language Processing
Presentation transcript:

November 2008NLP1 Natural Language Processing Definite Clause Grammars

November 2008NLP2 CF Recognition in Pure Prolog Use lists to represent strings. the monkey grinned [the,monkey,grinned] Reinterpret CF rules as Prolog clauses s  np vp s :- np, vp. Use append to concatenate the strings s(Z) :- np(X), vp(Y), append(X,Y,Z) Reinterpret lexical rules as simple assertions n  [monkey] becomes n([monkey]).

November 2008NLP3 Complete Recogniser Program s(Z) :-np(X), vp(Y), append(X,Y,Z). np(Z):-d(X),n(Y), append(X,Y,Z). vp(Z):-v(Z). d([the]). n([monkey]). v([grinned]). v([danced]).

November 2008NLP4 Running the Recogniser ?- s([the, monkey,grinned]). yes. ?- s([the, monkey,spat]). no. ?- s(X). X=[the,monkey,grinned]; X=[the,monkey,danced]

November 2008NLP5 Difference Lists Using append is very inefficient. We can avoid append by using difference lists. Key idea is to represent a string as the difference between two lists. For this purpose we employ two pointers.

November 2008NLP6 Difference Lists Here are different ways of representing the string a b c using pointers P1 and P2 P1:[a,b,c]P2:[ ] P1:[a,b,c,x]P2:[x] P1:[a,b,c,x,y]P2:[x,y] a b c x y P1 P2

November 2008NLP7 Recogniser Using Difference Lists s(X,Z) :-np(X,Y), vp(Y,Z). np(X,Z):-d(X,Y), n(Y,Z). vp(X,Y):-v(X,Y). d([the|Rest],Rest). n([monkey|Rest],Rest). v([grinned|Rest],Rest). v([danced|Rest],Rest).

November 2008NLP8 Running the Recogniser ?- s([the, monkey,grinned],[]). yes. ?- s([the, monkey,spat],[]). no. ?- s(X,[]). X=[the,monkey,grinned]; X=[the,monkey,danced]; no.

November 2008NLP9 Difference Lists Advantages append not used efficiency Disadvantages extra arguments in grammar rules grammar less readable Can we retain advantages and eliminate disadvantages ?

November 2008NLP10 Definite Clause Grammars (DCG) DCGs are just syntactic sugar Elimination of extra argument places Basic idea is still to look regard a grammar rule S  NP VP as an implication: NP & VP  S

November 2008NLP11 Definite Clause Grammars (DCGs) s --> np, vp. vp --> v. vp --> v, np. d --> [walks]. v --> [hits]. np --> [suzie]. np --> [fido].

November 2008NLP12 How DCGs are compiled We run the DCG recogniser in exactly the same way as we run the difference-list recogniser. The reason is that DCG notation is just syntactic sugar.The DCG rule x --> y, z. is actually compiled into an ordinary clause x(V1,V2) :- y(V1,V3), z(V3,V2). whilst the preterminal rule x --> [word]. compiles to the clause x([word|X],X]).

November 2008NLP13 Extra Arguments Even though we have eliminated variables in rules it is still possible to add extra arguments to which arbitrary terms can be bound. Later we will see how a rule x --> y, z. can be transformed into a rule x(Sx) --> y(Sy), z(Sz). where the red variables can be used to impose agreement or to carry semantic representations.

November 2008NLP14 Number Agreement This dog [  ] This dogs [  ] Those dogs [  ] Those dog [  ] np(sg) --> det(sg), n(sg). np(pl) --> det(pl), n(pl).

November 2008NLP15 Number Agreement This dog [  ] This dogs [  ] Those dogs [  ] Those dog [  ] np(sg) --> det(sg), n(sg). np(pl) --> det(pl), n(pl). np(N) --> det(N), n(N).

November 2008NLP16 Fixing the Grammar OLD GRAMMAR s --> np, vp. np --> n. np --> d, n. vp --> v np. NEW GRAMMAR s(N) --> np(N),vp(N). np(N) --> n(N). np(N) --> d(N),n(N). vp(N) --> v(N),np(_).

November 2008NLP17 Syntactic Structure Argument positions can contain arbitrary terms. For example, terms can be used to represent syntactic structure s( s(NP,VP) ) --> np(NP),vp(VP).

November 2008NLP18 Use of Curly Brackets Suppose we have s(Z) -> np(X), vp(Y). and there is an ordinary predicate p(X,Y,Z) which operates on the arguments. We enclose the ordinary predicate in curly brackets to avoid the automatic addition of two argument places. s(Z) -> np(X), vp(Y), {p(X,Y,Z)}

November 2008NLP19 Adding Features Suppose we wish to impose number agreement between np and vp To solve the problem of multiplying categories, we need to add feature constraints to our grammar specifications, in order to express the following sort of fact s  np vp constraint: number(np) = number(vp) Fortunately we can do just that because the constituents of rules can be full Prolog terms, which may include variables arguments.