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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Stabler - Lx 185/209 2003<br />

The sec<strong>on</strong>d file provides the interface to code from Shieber, Schabes, and Pereira (1993):<br />

/* closure-sics.pl<br />

* E. Stabler, 16 Oct 99<br />

* interface to the chart mechanism <strong>of</strong> Shieber, Schabes & Periera (1993)<br />

*/<br />

:- [’shieberetal93-sics/chart.pl’].<br />

:- [’shieberetal93-sics/agenda.pl’].<br />

:- [’shieberetal93-sics/items.pl’].<br />

:- [’shieberetal93-sics/m<strong>on</strong>itor.pl’].<br />

:- [’shieberetal93-sics/driver’].<br />

:- [’shieberetal93-sics/utilities’].<br />

closure(InitialSet,Closure) :init_chart,<br />

empty_agenda(Empty),<br />

add_items_to_agenda(InitialSet, Empty, Agenda),<br />

exhaust(Agenda),<br />

set<strong>of</strong>(Member,Indexˆstored(Index,Member),Closure).<br />

% item_to_key/2 should be specialized for the relati<strong>on</strong>s being computed<br />

item_to_key(F, Hash) :- hash_term(F, Hash).<br />

(40) The GLC parser that checks the oracle is then:<br />

/* file: glco.pl<br />

* E Stabler, Feb 2000<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). infer([W|S],[W|C],S,C). % shift-complete=scan<br />

infer([W|S],C,S,[-W|C]) :- nrR([-W|C]). % shift<br />

infer(S,RPC,S,DC) :- (A : ˜P+D), preverse(P,RPC,[A|C]), append(D,C,DC). % reduce-complete<br />

infer(S,RPC,S,DAC) :- (A : ˜P+D), preverse(P,RPC,C), nrR([-A|C]), append(D,[-A|C],DAC). % reduce<br />

%preverse(Expansi<strong>on</strong>D,ReversedExpansi<strong>on</strong>D,RestC<strong>on</strong>stituents)<br />

preverse([E|L],RD,C) :- preverse(L,RD,[-E|C]).<br />

preverse( [], C,C).<br />

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

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

92

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

Saved successfully!

Ooh no, something went wrong!