CS 603: Programming Languages - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

CS 603: Programming Languages

Description:

The grammar from last time didn't handle pronouns, so how do we fix it? Extend the grammar -or ... We can fix this with new rules. Fixing Sentence DCG. Pronouns ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 15
Provided by: csUa
Category:

less

Transcript and Presenter's Notes

Title: CS 603: Programming Languages


1
CS 603 Programming Languages
  • Lecture 28
  • Spring 2004
  • Department of Computer Science
  • University of Alabama
  • Joel Jones

2
Overview
  • More about Definite Clause Grammars
  • Adding arguments
  • Building parse trees

3
More on Definite Clause Grammars
  • Taken from
  • http//www.coli.uni-sb.de/kris/prolog-course/html
    /node66.html
  • The grammar from last time didnt handle
    pronouns, so how do we fix it?
  • Extend the grammar -or-
  • Use additional arguments

4
New Sentence DCG
  • Add pronouns to support sentences like
  • She shoots him and He shoots her

s --gt np,vp. np --gt det,n. np --gt
pro. vp --gt v,np. vp --gt v. det --gt the.
det --gt a. n --gt woman. n --gt man.
v --gt shoots. pro --gt he. pro ---gt
she. pro --gt him. pro --gt her.
s --gt np,vp. np --gt det,n. vp --gt v,np.
vp --gt v. det --gt the. det --gt a.
n --gt woman. n --gt man. v --gt shoots.
Becomes
5
Fixing Sentence DCG
  • Accepts incorrect sentences, such as
  • A woman shoots she, Her shoots she
  • Problem is there is no encoding of subject
    pronouns, such she and he or of object
    pronouns, such as her and his
  • We can fix this with new rules

6
Pronouns using Rules
s --gt np_subject,vp. np_subject --gt det,n. np_obj
ect --gt det,n. np_subject --gt pro_subject. np_obj
ect --gt pro_object. vp --gt v,np_object.
vp --gt v. det --gt the. det --gt a.
n --gt woman. n --gt man. v --gt shoots.
pro_subject --gt he. pro_object --gt
him. pro_subject ---gt she. pro_object --gt
her.
7
Pronouns using Arguments
s --gt np(subject),vp. np(_) --gt det,n. np(X) --gt
pro(X). vp --gt v,np(object). vp --gt v.
det --gt the. det --gt a. n --gt woman.
n --gt man. v --gt shoots. pro(subject) --gt
he. pro(object) --gt him. pro(subject) ---gt
she. pro(object) --gt her.
8
DCG Argument Implementation
s(A,B) - np(A,C), vp(C,B).
Is syntactic sugar for
s --gt np,vp.
And
s(A,B) - np(subject,A,C), vp(C,B).
Is syntactic sugar for
s --gt np(subject),vp.
np(A,B,C) - det(B,D), n(D,C). np(A,B,C) 
- pro(A,B,C.
Is syntactic sugar for
np(_) --gt det,n. np(X) --gt pro(X).
9
New Sentence DCG at Work
? np(X,NP,). X  _2625 NP  the,woman    X  
_2625 NP  the,man    X  _2625 NP  a,woman 
  X  _2625 NP  a,man 
X  subject   NP  he    X  subject  
NP  she    X  object   NP  him 
  X  object   NP  her    no
10
Building Parse Trees
  • How do we represent and build a parse tree?
  • In other words, for the tree below on the left,
    produce the term below on the right.

s(np(det(a), n(woman), vp(v(shoots),
np(det(a), n(man))).
11
Building Parse Trees (cont.)
s(s(NP,VP)) --gt np(NP), vp(VP).
np(np(DET,N)) --gt det(DET),
n(N). vp(vp(V,NP)) --gt v(V),
np(NP). vp(vp(V))    --gt v(V).
det(det(the)) --gt the. det(det(a))   --gt a.
n(n(woman)) --gt woman. n(n(man))   --gt man.
v(v(shoots)) --gt shoots.
12
DCGs for non-CFGs
  • Consider the formal language
  • anbncn - e which consists of all non-null strings
    which consist of n as followed by n bs
    followed by n cs

13
DCGs for non-CFGs (cont.)
s(Count) --gt ablock(Count),
bblock(Count), cblock(Count).
ablock(0) --gt . ablock(succ(Count)) --gt a,ab
lock(Count). bblock(0) --gt .
bblock(succ(Count)) --gt b,bblock(Count).
cblock(0) --gt . cblock(succ(Count)) --gt c,cb
lock(Count).
14
DCGs for non-CFGs Example
?- s(Count,L,). Count 0 L Count
succ(0) L a, b, c Count succ(succ(0)) L
a, a, b, b, c, c Count
succ(succ(succ(0))) L a, a, a, b, b, b, c, c,
c
Write a Comment
User Comments (0)
About PowerShow.com