21
1 Definite Clause Grammars for Language Analysis – A Survey of the Formalism and a Comparison with Augmented Transition Networks 인인인인 인인인 Hee keun Heo

인공지능 연구실 Hee keun Heo

  • Upload
    sabina

  • View
    48

  • Download
    0

Embed Size (px)

DESCRIPTION

Definite Clause Grammars for Language Analysis – A Survey of the Formalism and a Comparison with Augmented Transition Networks. 인공지능 연구실 Hee keun Heo. Introduction. By Fernando C. N. Pereira and David H. D. Warren Introduction to logic as s programming language and to Prolog. - PowerPoint PPT Presentation

Citation preview

Page 1: 인공지능 연구실 Hee keun Heo

1

Definite Clause Grammars for Language Analysis – A Survey of the Formalism and a Comparison

with Augmented Transition Networks

인공지능 연구실Hee keun Heo

Page 2: 인공지능 연구실 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

Page 3: 인공지능 연구실 Hee keun Heo

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 built in the course of the parsing

• DCGs allow extra conditions to be included in the grammar rules

Page 4: 인공지능 연구실 Hee keun Heo

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)

Page 5: 인공지능 연구실 Hee keun Heo

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.

Page 6: 인공지능 연구실 Hee keun Heo

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)

Page 7: 인공지능 연구실 Hee keun Heo

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

Page 8: 인공지능 연구실 Hee keun Heo

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

Page 9: 인공지능 연구실 Hee keun Heo

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}

Page 10: 인공지능 연구실 Hee keun Heo

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

Page 11: 인공지능 연구실 Hee keun Heo

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 f

orm• 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. 1 2 3 4 5 6 7

» Sentence(S) from 1 to 7 <- initial goals» S = s(NP,VP) <- match the single r

ule» noun_phrase(N,NP) from 1 to P1 <- goal

verb_phrase(N,VP) from P1 to 7 <- goal

Page 12: 인공지능 연구실 Hee keun Heo

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

Page 13: 인공지능 연구실 Hee keun Heo

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.

Page 14: 인공지능 연구실 Hee keun Heo

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.

Page 15: 인공지능 연구실 Hee keun Heo

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

Page 16: 인공지능 연구실 Hee keun Heo

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 f

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

Page 17: 인공지능 연구실 Hee keun Heo

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 provid

e 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 –ri

ght

• But DCG is primarily a language description, neutral towards implementation

• As a result, a DCG can be executed in a variety of different ways.

Page 18: 인공지능 연구실 Hee keun Heo

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.

Page 19: 인공지능 연구실 Hee keun Heo

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

Page 20: 인공지능 연구실 Hee keun Heo

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 ling

uists and philosophers

Page 21: 인공지능 연구실 Hee keun Heo

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