20.07.2013 Views

Notes on computational linguistics.pdf - UCLA Department of ...

Notes on computational linguistics.pdf - UCLA Department of ...

Notes on computational linguistics.pdf - UCLA Department of ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Stabler - Lx 185/209 2003<br />

(18) Throughout our study, we will keep an eye <strong>on</strong> these basic properties <strong>of</strong> syntactic analysis algorithms<br />

which are menti<strong>on</strong>ed in these facts:<br />

1. First, we would like our deductive system to be sound (if s can be derived from A, thencan be<br />

deduced from axioms s and goal ?-A) and complete (if can be deduced from axioms s and goal ?-A,<br />

then s can be derived from A), and we also prefer to avoid spurious ambiguity. That is, we would<br />

like there to be n pro<strong>of</strong>s just in case there are n corresp<strong>on</strong>ding derivati<strong>on</strong>s from the grammar.<br />

2. Furthermore, we would prefer for there to be a substantial subset <strong>of</strong> the language that can be recognized<br />

with finite memory.<br />

3. Finally, we would like the search space for any particular input to be finite.<br />

(19) Let’s call the grammar c<strong>on</strong>sidered earlier, G1, implemented in g1.pl as follows:<br />

:- op(1200,xfx,:˜).<br />

ip :˜ [dp, i1]. i1 :˜ [i0, vp]. i0 :˜ [will].<br />

dp :˜ [d1]. d1 :˜ [d0, np]. d0 :˜ [the].<br />

np :˜ [n1]. n1 :˜ [n0]. n0 :˜ [idea].<br />

n1 :˜ [n0, cp].<br />

vp :˜ [v1]. v1 :˜ [v0]. v0 :˜ [suffice].<br />

cp :˜ [c1]. c1 :˜ [c0, ip]. c0 :˜ [that].<br />

(20) Let’s call this top-down, backtracking recognizer, c<strong>on</strong>sidered last time, td.pl:<br />

/*<br />

* file: td.pl = ll.pl<br />

*<br />

*/<br />

:- op(1200,xfx,:˜ ). % this is our object language "if"<br />

:- op(1100,xfx,?˜ ). % metalanguage provability predicate<br />

[] ?˜ [].<br />

(S0 ?˜ Goals0) :- infer(S0,Goals0,S,Goals), (S ?˜ Goals).<br />

infer(S,[A|C], S,DC) :- (A :˜ D), append(D,C,DC). % ll<br />

infer([A|S],[A|C], S,C). % scan<br />

append([],L,L).<br />

append([E|L],M,[E|N]) :- append(L,M,N).<br />

(21) We can store the grammar in separate files, g1.pl and td.pl, and load them both:<br />

1?-[td,g1].<br />

td compiled, 0.00 sec, 1,116 bytes.<br />

g1 compiled, 0.00 sec, 1,804 bytes.<br />

Yes<br />

2 ?- [the,idea,will,suffice] ?˜[ip].<br />

Yes<br />

3 ?- [the,idea,that,the,idea,will,suffice,will,suffice] ?˜[ip].<br />

Yes<br />

4 ?- [will,the,idea,suffice] ?˜[ip].<br />

No<br />

5?-halt.<br />

45

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!