09.04.2003CSA2050: DCG I1 CSA2050 Introduction to Computational Linguistics Lecture 8 Definite Clause Grammars.

Slides:



Advertisements
Similar presentations
Artificial Intelligence: Natural Language and Prolog
Advertisements

Prolog programming....Dr.Yasser Nada. Chapter 8 Parsing in Prolog Taif University Fall 2010 Dr. Yasser Ahmed nada prolog programming....Dr.Yasser Nada.
October 2004CSA4050: Semantics III1 CSA4050: Advanced Topics in NLP Semantics III Quantified Sentences.
November 2008NLP1 Natural Language Processing Definite Clause Grammars.
07/05/2005CSA2050: DCG31 CSA2050 Introduction to Computational Linguistics Lecture DCG3 Handling Subcategorisation Handling Relative Clauses.
CSA4050: Advanced Topics in NLP Semantics IV Partial Execution Proper Noun Adjective.
CSA2050: DCG IV1 CSA2050: Definite Clause Grammars IV Handling Gaps II Semantic Issues.
May 2006CLINT-LN Parsing1 Computational Linguistics Introduction Approaches to Parsing.
Grammars, Languages and Parse Trees. Language Let V be an alphabet or vocabulary V* is set of all strings over V A language L is a subset of V*, i.e.,
DEFINITE CLAUSE GRAMMARS Ivan Bratko University of Ljubljana Faculty of Computer and Information Sc.
GRAMMAR & PARSING (Syntactic Analysis) NLP- WEEK 4.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 7: 9/12.
Introduction to Computational Linguistics Lecture 2.
Parsing: Features & ATN & Prolog By
LING 364: Introduction to Formal Semantics
Syllabus Text Books Classes Reading Material Assignments Grades Links Forum Text Books עיבוד שפות טבעיות - שיעור עשר Chart Parsing (cont) Features.
LING 388 Language and Computers Lecture 8 9/25/03 Sandiway FONG.
LING 364: Introduction to Formal Semantics Lecture 4 January 24th.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 6: 9/7.
LING 438/538 Computational Linguistics Sandiway Fong Lecture 5: 9/5.
Chapter 3: Formal Translation Models
LING 364: Introduction to Formal Semantics Lecture 5 January 26th.
LING 388: Language and Computers Sandiway Fong Lecture 13: 10/10.
Context-Free Grammar CSCI-GA.2590 – Lecture 3 Ralph Grishman NYU.
LING 388: Language and Computers Sandiway Fong Lecture 8.
LING 388: Language and Computers Sandiway Fong 10/4 Lecture 12.
(2.1) Grammars  Definitions  Grammars  Backus-Naur Form  Derivation – terminology – trees  Grammars and ambiguity  Simple example  Grammar hierarchies.
11 CS 388: Natural Language Processing: Syntactic Parsing Raymond J. Mooney University of Texas at Austin.
February 2009Introduction to Semantics1 Logic, Representation and Inference Introduction to Semantics What is semantics for? Role of FOL Montague Approach.
October 2004csa4050: Semantics II1 CSA4050: Advanced Topics in NLP Semantics II The Lambda Calculus Semantic Representation Encoding in Prolog.
1 Syntax and Semantics The Purpose of Syntax Problem of Describing Syntax Formal Methods of Describing Syntax Derivations and Parse Trees Sebesta Chapter.
ICS611 Introduction to Compilers Set 1. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine.
October 2008csa3180: Setence Parsing Algorithms 1 1 CSA350: NLP Algorithms Sentence Parsing I The Parsing Problem Parsing as Search Top Down/Bottom Up.
For Friday Finish chapter 23 Homework: –Chapter 22, exercise 9.
LING 388: Language and Computers Sandiway Fong Lecture 7.
CSI 3120, Grammars, page 1 Language description methods Major topics in this part of the course: –Syntax and semantics –Grammars –Axiomatic semantics (next.
Winter 2007SEG2101 Chapter 71 Chapter 7 Introduction to Languages and Compiler.
Syntax Specification and BNF © Allan C. Milne Abertay University v
Syntax and Backus Naur Form
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.
October 2005csa3180: Parsing Algorithms 11 CSA350: NLP Algorithms Sentence Parsing I The Parsing Problem Parsing as Search Top Down/Bottom Up Parsing Strategies.
7. Parsing in functional unification grammar Han gi-deuc.
October 2004CSA4050: Semantics III1 CSA4050: Advanced Topics in NLP Semantics III Quantified Sentences.
2007CLINT-LIN-FEATSTR1 Computational Linguistics for Linguists Feature Structures.
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.
November 2011CLINT-LN CFG1 Computational Linguistics Introduction Context Free Grammars.
1 Definite Clause Grammars for Language Analysis – A Survey of the Formalism and a Comparison with Augmented Transition Networks 인공지능 연구실 Hee keun Heo.
CSA2050 Introduction to Computational Linguistics Lecture 1 What is Computational Linguistics?
Daisy Arias Math 382/Lab November 16, 2010 Fall 2010.
Rules, Movement, Ambiguity
Artificial Intelligence: Natural Language
CSA2050 Introduction to Computational Linguistics Parsing I.
November 2004csa3050: Sentence Parsing II1 CSA350: NLP Algorithms Sentence Parsing 2 Top Down Bottom-Up Left Corner BUP Implementation in Prolog.
csa3050: Parsing Algorithms 11 CSA350: NLP Algorithms Parsing Algorithms 1 Top Down Bottom-Up Left Corner.
1 Introduction to Computational Linguistics Eleni Miltsakaki AUTH Fall 2005-Lecture 3.
CSC312 Automata Theory Lecture # 26 Chapter # 12 by Cohen Context Free Grammars.
Finite State LanguagesCSE Intro to Cognitive Science1 The Computational Modeling of Language: Finite State Languages Lecture I: Slides 1-21 Lecture.
April 2010Semantic Grammar1 A short guide to Blackburn’s Grammar of English.
November 2004csa3050: Parsing Algorithms 11 CSA350: NLP Algorithms Parsing Algorithms 1 Top Down Bottom-Up Left Corner.
7.2 Programming Languages - An Introduction to Informatics WMN Lab. Hye-Jin Lee.
10/31/00 1 Introduction to Cognitive Science Linguistics Component Topic: Formal Grammars: Generating and Parsing Lecturer: Dr Bodomo.
Natural Language Processing Vasile Rus
Introduction to Parsing (adapted from CS 164 at Berkeley)
Natural Language Processing
CSA2050 Introduction to Computational Linguistics
csa3180: Setence Parsing Algorithms 1
CSA4050: Advanced Topics in NLP
Lecture 7: Definite Clause Grammars
Presentation transcript:

CSA2050: DCG I1 CSA2050 Introduction to Computational Linguistics Lecture 8 Definite Clause Grammars

CSA2050: DCG I2 Rationale Logic CFG + Sentence Prolog Program Sentence Structure

CSA2050: DCG I3 Logic Rules and Grammar Rules Basic Question: what is the connection between logic rules and grammar rules?  x  y male(x) & parent(x,y) → father(x,y ) S → NP VP They are both concerned with the definition of predicates.

CSA2050: DCG I4 Logic Rules and Grammar Rules Logic: arbitrary n-ary predicates, eg raining; clever(x); father(x,y); between(x,y,z) Grammar Rules: predicates over text segments, eg np(x); vp(y); s(z).

CSA2050: DCG I5 Text Segments A text segment is a sequence of consecutive words. A text segment can be identified by two pointers, if we assign names to the spaces between words. 0 the 1 cat 2 sat 3 on 4 the 5 mat 6 (0,6) is the whole sentence (0,2) is the first noun phrase

CSA2050: DCG I6 From Grammar Rules to Logic The general statement made by the CF rule S → NP, VP can be summarised using predicates over segments with the following logic statement NP(p1,p) & VP(p,p2) => S(p1,p2)

CSA2050: DCG I7 From Grammar Rules to Logic 0 the 1 cat 2 sat 3 on 4 the 5 mat 6 NP VP S

CSA2050: DCG I8 From Logic to Prolog Each logic statement of the form NP(p1,p) & VP(p,p2) => S(p1,p2) Corresponds to the "definite clause" s(P1,P2) :- np(P1,P), vp(P,P2).

CSA2050: DCG I9 Converting a Grammar S → NP, VP NP → N NP → Det N VP → V NP s(P1,P2) :- np(P1,P), vp(P,P2). np(P1,P2) :- n(P1,P2). np(P1,P2) :- det(P1,P), n(P,P2). vp(P1,P2) :- v(P1,P), np(P, P2)

CSA2050: DCG I10 Lexical Categories and Rules Lexical categories are those which are not defined in the grammar itself (eg. N and V in our grammar) Instead, they are defined by the words that they rewrite V → run, sleep, talk etc Lexical categories always derive exactly one input token.

CSA2050: DCG I11 Lexical Rules A rule defining lexical category C must express the following information: there is a C between positions p1 and p2 if some word of syntactic category C spans those positions There are many different ways to translate such a rule into a Prolog clause. Each way needs to make reference to how the input sentence is represented.

CSA2050: DCG I12 Defining Lexical Categories Each category is defined in terms of the words it can rewrite d(P1,P2) :- input(P1,P2,[the]). n(P1,P2) :- input(P1,P2,[cat]). n(P1,P2) :- input(P1,P2,['John']). v(P1,P2) :- input(P1,P2,[ate]). How is the input sentence represented?

CSA2050: DCG I13 Representing the Input Define the predicate input(P1,P2,L) such that P1 and P2 are positions and L is a list containing the words spanning those positions Checkpoint: show how to represent the input sentence "John ate the cat"

CSA2050: DCG I14 John ate the cat input(0,1,['John']). input(1,2,[ate]). input(2,3,[the]). input(3,4,[cat]). Checkpoints Why is John in quotes? Why use a list of one element rather than an atom? Is this the only way to do it?

CSA2050: DCG I15 Complete Program 1. Grammar s(P1,P2) :- np(P1,P), vp(P,P2). np(P1,P2) :- n(P1,P2). np(P1,P2) :- d(P1,P), n(P,P2). vp(P1,P2) :- v(P1,P2). vp(P1,P2) :- v(P1,P), np(P, P2) 2. Lexicon d(P1,P2) :- input(P1,P2,[the]). n(P1,P2) :- input(P1,P2,[cat]). n(P1,P2) :- input(P1,P2,['John']). v(P1,P2) :- input(P1,P2,[ate]). 3. Input input(0,1,['John']). input(1,2,[ate]). input(2,3,[the]). input(3,4,[cat]). 4. Query ?- s(0,4).

CSA2050: DCG I16 Trace of query?- vp(1,4) 1 1 Call: vp(1,4) ? 2 2 Call: v(1,4) ? 3 3 Call: input(1,4,[ate]) ? 3 3 Fail: input(1,4,[ate]) ? 2 2 Fail: v(1,4) ? 2 2 Call: v(1,_349) ? 3 3 Call: input(1,_349,[ate]) ? 3 3 Exit: input(1,2,[ate]) ? 2 2 Exit: v(1,2) ? 4 2 Call: np(2,4) ? 5 3 Call: n(2,4) ? 6 4 Call: input(2,4,[cat]) ? 6 4 Fail: input(2,4,[cat]) ? 6 4 Call: input(2,4,[John]) ? 6 4 Fail: input(2,4,[John]) ? 5 3 Fail: n(2,4) ? 5 3 Call: d(2,_1338) ? 6 4 Call: input(2,_1338,[the]) ? 6 4 Exit: input(2,3,[the]) ? 5 3 Exit: d(2,3) ? 7 3 Call: n(3,4) ? 8 4 Call: input(3,4,[cat]) ? 8 4 Exit: input(3,4,[cat]) ? 7 3 Exit: n(3,4) ? 4 2 Exit: np(2,4) ? 1 1 Exit: vp(1,4) ?

CSA2050: DCG I17 Representing the Sentence Using Difference Lists We can represent the input as a pair of pointers The first pointer points to the entire list The second pointer points to a suffix of the list. The represented list is the difference between the two lists. input(['John',ate,the,cat],['John',ate,the,cat]). input(['John',ate,the,cat],[ate,the,cat]). input(['John',ate,the,cat],[the,cat]). input(['John',ate,the,cat],[]). input([X|Y],Y,X).

CSA2050: DCG I18 DCG Notation The conversion of CF rules into Prolog is so simple that it can be done automatically. Clauses in DCG notation: s --> np, vp. np --> d, n. n --> [cat]. are automatically translated when read in to s(P1,P2) --> np(P1,P),vp(P,P2). np(P1,P2) --> d(P1,P), n(P,P2). n([dog|L],L).

CSA2050: DCG I19 DCG Notation Every DCG rule takes the form nonterminal --> expansion where expansion is any of A nonterminal symbol np A list of non-terminal symbols [each,other] A null constitutent [ ] A plain Prolog goal enclosed in braces {write('Found')} A series of any of these expansions joined by commas.

CSA2050: DCG I20 Complete DCG 1. Grammar s --> np, vp. np --> n. np --> d, n. vp --> v. vp --> v, np 2. Lexicon d --> [the]. n --> [cat]. n --> ['John']. v --> ['ate']. 3. Input 4. Query ?- s(['john', ate, the, cat], []).

CSA2050: DCG I21 Checkpoints What is your system's translation of s --> np, vp. n --> [cat].