1 Definite Clause Grammars for Language Analysis – A Survey of the Formalism and a Comparison with Augmented Transition Networks 인공지능 연구실 Hee keun Heo.

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.
Augmented Transition Networks
CSA2050: DCG I1 CSA2050 Introduction to Computational Linguistics Lecture 8 Definite Clause Grammars.
ICE1341 Programming Languages Spring 2005 Lecture #6 Lecture #6 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University.
C O N T E X T - F R E E LANGUAGES ( use a grammar to describe a language) 1.
Answer Set Programming Overview Dr. Rogelio Dávila Pérez Profesor-Investigador División de Posgrado Universidad Autónoma de Guadalajara
Grammars, constituency and order A grammar describes the legal strings of a language in terms of constituency and order. For example, a grammar for a fragment.
ISBN Chapter 3 Describing Syntax and Semantics.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Defining practical programming languages Carlos Varela RPI.
Amirkabir University of Technology Computer Engineering Faculty AILAB Efficient Parsing Ahmad Abdollahzadeh Barfouroush Aban 1381 Natural Language Processing.
Chapter 3 Describing Syntax and Semantics Sections 1-3.
Amirkabir University of Technology Computer Engineering Faculty AILAB Parsing Ahmad Abdollahzadeh Barfouroush Aban 1381 Natural Language Processing Course,
Context-Free Grammars Lecture 7
Features and Unification
Chapter 3 Describing Syntax and Semantics Sections 1-3.
Chapter 3 Describing Syntax and Semantics Sections 1-3.
Dr. Muhammed Al-Mulhem 1ICS ICS 535 Design and Implementation of Programming Languages Part 1 Fundamentals (Chapter 4) Compilers and Syntax.
Chapter 3: Formal Translation Models
Specifying Languages CS 480/680 – Comparative Languages.
Context-Free Grammar CSCI-GA.2590 – Lecture 3 Ralph Grishman NYU.
(2.1) Grammars  Definitions  Grammars  Backus-Naur Form  Derivation – terminology – trees  Grammars and ambiguity  Simple example  Grammar hierarchies.
Context Free Grammars Reading: Chap 12-13, Jurafsky & Martin This slide set was adapted from J. Martin, U. Colorado Instructor: Paul Tarau, based on Rada.
Chapter 2 Syntax A language that is simple to parse for the compiler is also simple to parse for the human programmer. N. Wirth.
1 Syntax and Semantics The Purpose of Syntax Problem of Describing Syntax Formal Methods of Describing Syntax Derivations and Parse Trees Sebesta Chapter.
1 Introduction to Parsing Lecture 5. 2 Outline Regular languages revisited Parser overview Context-free grammars (CFG’s) Derivations.
Syntax & Semantic Introduction Organization of Language Description Abstract Syntax Formal Syntax The Way of Writing Grammars Formal Semantic.
Formal Models of Computation Part II The Logic Model
Design Pattern Interpreter By Swathi Polusani. What is an Interpreter? The Interpreter pattern describes how to define a grammar for simple languages,
CS 355 – PROGRAMMING LANGUAGES Dr. X. Topics Introduction The General Problem of Describing Syntax Formal Methods of Describing Syntax.
1 Chapter 3 Describing Syntax and Semantics. 3.1 Introduction Providing a concise yet understandable description of a programming language is difficult.
A sentence (S) is composed of a noun phrase (NP) and a verb phrase (VP). A noun phrase may be composed of a determiner (D/DET) and a noun (N). A noun phrase.
CS 331, Principles of Programming Languages Chapter 2.
CS Describing Syntax CS 3360 Spring 2012 Sec Adapted from Addison Wesley’s lecture notes (Copyright © 2004 Pearson Addison Wesley)
PART I: overview material
3-1 Chapter 3: Describing Syntax and Semantics Introduction Terminology Formal Methods of Describing Syntax Attribute Grammars – Static Semantics Describing.
An Intelligent Analyzer and Understander of English Yorick Wilks 1975, ACM.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
ISBN Chapter 3 Describing Syntax and Semantics.
TextBook Concepts of Programming Languages, Robert W. Sebesta, (10th edition), Addison-Wesley Publishing Company CSCI18 - Concepts of Programming languages.
CMSC 330: Organization of Programming Languages Context-Free Grammars.
CSE 425: Syntax II Context Free Grammars and BNF In context free grammars (CFGs), structures are independent of the other structures surrounding them Backus-Naur.
D Goforth COSC Translating High Level Languages.
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
ISBN Chapter 3 Describing Semantics.
Chapter 3 Part II Describing Syntax and Semantics.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
Copyright © 2006 Addison-Wesley. All rights reserved. Ambiguity in Grammars A grammar is ambiguous if and only if it generates a sentential form that has.
D Goforth COSC Translating High Level Languages Note error in assignment 1: #4 - refer to Example grammar 3.4, p. 126.
Chapter 3 Describing Syntax and Semantics
Basic Parsing Algorithms: Earley Parser and Left Corner Parsing
November 2004csa3050: Sentence Parsing II1 CSA350: NLP Algorithms Sentence Parsing 2 Top Down Bottom-Up Left Corner BUP Implementation in Prolog.
ISBN Chapter 3 Describing Syntax and Semantics.
1 / 48 Formal a Language Theory and Describing Semantics Principles of Programming Languages 4.
CS 331, Principles of Programming Languages Chapter 2.
Syntax and Grammars.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Overview of Previous Lesson(s) Over View  In our compiler model, the parser obtains a string of tokens from the lexical analyzer & verifies that the.
Grammars Hopcroft, Motawi, Ullman, Chap 5. Grammars Describes underlying rules (syntax) of programming languages Compilers (parsers) are based on such.
Grammars CS 130: Theory of Computation HMU textbook, Chap 5.
The Interpreter Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
1-1 An Introduction to Logical Programming Sept
Parser: CFG, BNF Backus-Naur Form is notational variant of Context Free Grammar. Invented to specify syntax of ALGOL in late 1950’s Uses ::= to indicate.
©SoftMoore ConsultingSlide 1 Context-Free Grammars.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Syntax.
Describing Syntax and Semantics
CS 3304 Comparative Languages
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Teori Bahasa dan Automata Lecture 9: Contex-Free Grammars
COMPILER CONSTRUCTION
Presentation transcript:

1 Definite Clause Grammars for Language Analysis – A Survey of the Formalism and a Comparison with Augmented Transition Networks 인공지능 연구실 Hee keun Heo

2 Introduction  By Fernando C. N. Pereira and David H. D. Warren  Introduction to logic as s programming language and to Prolog.  Explain the basic definite clause grammars(DCG) formalism  How ATN can be translated into DCG  Advantages of DCG relative to ATN

3 Logic as a Programming Language – The Definite Clause Subset(1)  Definite Clause : “Horn clauses” or “regular clauses” –DCGs are a natural extension of CFGs. –CFGs are not fully adequate for describing natural language -> DCGs overcome this in adequacy by extending CFGs in three important ways DCGs provide for context-dependency in a grammar DCGs allow arbitrary tree structures to be builtin the course of the parsing DCGs allow extra conditions to be included in the grammar rules

4 Logic as a Programming Language – The Definite Clause Subset(2)  Syntax, terminology and informal semantics –Terms : the data objects of the language Constant Variables Compound term –the structured data objects of the language –Functor(record type) + sequence of Arguments(fields of a record)

5 Logic as a Programming Language – The Definite Clause Subset(3)  A logic program consists of a sequence of statements called clauses.  Clause –Head : single goal or empty –Body : consists of a sequence of zero or more goals –Non-unit clause : neither the head nor the body of the clause is empty Form -> P :- Q, R, S. –Unit clause : body of the clause is empty Form -> P. –Clause a question : the head of the clause is empty Form -> ?- P, Q.

6 Logic as a Programming Language – The Definite Clause Subset(4)  The goal in the body of a clause are linked by the operator –‘,’ : conjunction(“and”) –‘;’ : disjunction(“or”) –Precedence : (:-) -> (;) -> (,) –Example Grandfather(X,Z) :- (mother(X,Y); father(X,Y)), father(Y,Z) –For any X, Y and Z X has Z as a grandfather if either the mother of X is Y or father of X is Y, and the father of Y is Z. Grandfather(X,Z) :- parent(X,Y), father(Y,Z) parent(X,Y) :- mother(X,Y) parent(X,Y) :- father(X,Y)

7 How to Write Grammars in Logic – Expressing context-free grammars in definite clauses  “John loves Mary” and “Every man that lives loves a woman” CFG 2-place predicate 3-place predicate translate

8 How to Write Grammars in Logic - Definite clause grammars(1)  Notation –The notation for DCGs extends our notation for CFGs Non-terminal are allowed to be compound terms in addition to the simple atoms allowed in the context-free case –np(X,S) sentence(S) In the right-hand side of a rule, in addition to non-terminals, lists of terminals and sequences of procedure call(written within the brackets ‘{‘ and ‘}’ – extra condition) –Noun(N) -> [W], {rootform(W,N), is_noun(N)}

9 How to Write Grammars in Logic - The use of definite clause grammars(1)  Building structures(such as parse trees) –Way of representing the dictionary : more compact, more efficient Rule of the form Category(arguments) -> [word] General rule Category(arguments) ->[w], {cat(W, arguments}

10 How to Write Grammars in Logic - The use of definite clause grammars(2)  Extra conditions –Date(D,M) -> month(M), [D], {integer(D), 0< D, D<32}  Context dependency

11 How DCGs are executed by Prolog  The grammar rules are used top-down  Goals in a rule are executed from left to right. –Sentence is parsed from left to right. –Prolog goals coming from DCG non-terminals or terminals in the form Symbol from point1 to point2 –Symbol : non-terminal or list of terminals –Point1, point2 : positions in the input string –That man that whistles tunes pianos »Sentence(S)from 1 to 7 <- initial goals »S = s(NP,VP) <- match the single rule »noun_phrase(N,NP) from 1 to P1 <- goal verb_phrase(N,VP) from P1 to 7 <- goal

12 How to Translate ATNs into DCGs - Decomposing the network(1)  How an unaugmented transition network translates into a DCG which is simply a CFG.(Wood(1970))

13 How to Translate ATNs into DCGs - Decomposing the network(2)  Boxes identify a decomposition into the simple networks s -> np, verb, object. s -> aux, np, v, object. verb -> v. verb -> aux, v. object -> np, pps. object -> []. np-> det, adjs, n, pps np -> npr. adjs -> adj, adjs. adjs -> []. pps -> pp, pps. pps -> []. pp -> prep, np.

14 How to Translate ATNs into DCGs - Decomposing the network(3)  In general, a more concise translation is obtained if each simple network obeys a minimality constraint. –The different paths through the network only meet at the start and end nodes.

15 How to Translate ATNs into DCGs - Translating the arcs(1)  Assume that the Lisp test in an arc is translated into a goal, test, and the Lisp actions into a sequence of goals, actions. –Each are type is then translated as follows in the body of a rule. (CAT category …)[W], {test, category(W), actions}, (WRD word …)[word], {test, actions}, (MEM list …)[W], {test, in(W,list), actions}. (TST …)[W], {test, actions}, (JUMP …){test, actions}, (PUSH subnetwork …){test}, subnetwork, {actions}, (POP …){test, actions}.

16 The Advantages of DCGs(1)  Perspicuity : area where DCGs show the most marked improvement over ATNs. –DCGs can be understood in a way which is qualitatively different from the way one understands an ATN. Like an ATN, a DCG can be understood as a machine for analysing a particular language. Unlike an ATN, a DCG can also be understood as a description of a language. –DCGs are more modular. The machinery of a DCG is made up of small components(clauses) –There are no global variables : the scope of each variable is limited to a single clause.

17 The Advantages of DCGs(2)  Power and generality : considering what can and cannot, be expressed in the formalism – in both a theoretical and a practical sense –In this context, one of the key features of DCGs is that they provide an essentially more powerful mechanism for building structures than is available in ATNs. –DCGs are more general than ATNs ATN is particular machine for parsing a language top-down left-to – right But DCG is primarily a language description, neutral towards implementation As a result, a DCG can be executed in a variety of different ways.

18 The Advantages of DCGs(3)  Conciseness –DCGs are more concise than ATNs Logic programs are in general more concise than programs in conventional languages. Thu use of pattern matching instead of explicit operations for setting and testing registers and building structures.

19 The Advantages of DCGs(4)  Efficiency –DCGs do not need a special interpreter or compiler. Why? DCG is expressed directly in a general purpose programming language But ATN needs a special interpreter or compiler. –Above all, a DCG is merely a particular kind of program in an efficient and general purpose programming language But an ATN is a special purpose formalism

20 The Advantages of DCGs(5)  Flexibility –The DCG formalism is more flexible than ATNs It is in no way tied to a particular parsing or execution mechanism. Writing a grammar as a DCG makes it much easier to experiment with radically different parsing strategies.  Suitability for theoretical work –Unlike ATNs, DCGs can also be a useful formalism for theoretical studies of language They potentially provide a bridge between the work of theoretical linguists and philosophers

21 Conclusion  On both practical and philosophical grounds, we believe DCGs represent a significant advance over ATNs.  Considered as practical tools for implementing language analysers, DCGs are in a real sense more powerful than ATNs  On the practical side, the greater clarity and modularity of DCGs is a vital aid in the actual development of systems of the size and complexity necessary for real natural language analysis – DCG consists of small independent rules  On the philosophical side, DCGs are significant because they potentially provide a common formalism for theoretical work and for writing efficient natural language systems