Notes on computational linguistics.pdf - UCLA Department of ...
Notes on computational linguistics.pdf - UCLA Department of ...
Notes on computational linguistics.pdf - UCLA Department of ...
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 />
(37) Example. C<strong>on</strong>sider again g5-mix.pl given in (32) above. There are infinitely many derivati<strong>on</strong>s <strong>of</strong> this<br />
trivial result:<br />
[n1] Rn1 [unreduce]<br />
[n1] Rn1 [unreduce]<br />
[n1] Rn1 [unreduce]<br />
...<br />
Nevertheless, the set <strong>of</strong> theorems, the set <strong>of</strong> pairs in the “is a beginning <strong>of</strong>” relati<strong>on</strong> for the grammar<br />
g5-mix.pl with the trigger relati<strong>on</strong>s indicated there, is finite.<br />
We can compute the whole set by taking the closure <strong>of</strong> the axioms under the inference relati<strong>on</strong>.<br />
(38) Another wrinkle for the implementati<strong>on</strong>: we store our beginnings in reversed, negated form, to make<br />
it maximally easy to apply them in GLC reas<strong>on</strong>ing.<br />
¬qi,...,¬q1 nr R p [axiom-r] if p:-q1,...,qi ][q i+1,...,qn<br />
¬qi,...,¬q1 nr R p [unscan-r] if qi ∈ Σ<br />
¬qi−1,...,¬q1 nr R p<br />
¬qi,...,¬q1 nr R p<br />
¬rj,...,¬r1, ¬qi−1,...,¬q1 nr R p<br />
[unreduce-r] if qi:-r1,...,rj ][r j+1,...,rn<br />
(39) We will use code from Shieber, Schabes, and Pereira (1993) to compute the closure <strong>of</strong> these axioms<br />
under the inference rules. 26<br />
The following two files do what we want. (We have <strong>on</strong>e versi<strong>on</strong> specialized for sicstus prolog, and <strong>on</strong>e<br />
for swiprolog.)<br />
/* oracle-sics.pl<br />
* E Stabler, Feb 2000<br />
*/<br />
:- op(1200,xfx,: ˜ ). % this is our object language "if"<br />
:- [’closure-sics’]. % defines closure/2, uses inference/4<br />
:- use_module(library(lists),[append/3,member/2]).<br />
%verbose. % comment to reduce verbosity <strong>of</strong> chart c<strong>on</strong>structi<strong>on</strong><br />
computeOracle :- abolish(nrR), set<strong>of</strong>(Axiom,axiomr(Axiom),Axioms), closure(Axioms, Chart), asserts(Chart).<br />
axiomr(nrR(NRBA)) :- (A : ˜B+_), negreverse(B,[A|_],NRBA).<br />
negreverse([],M,M).<br />
negreverse([E|L],M,N) :- negreverse(L,[-E|M],N).<br />
inference(unreduce-r/2,<br />
[ nrR([-Qi|Qs]) ],<br />
nrR(NewSeq),<br />
[(Qi : ˜Prefix+_), negreverse(Prefix,[],NRPrefix),<br />
append(NRPrefix,Qs,NewSeq) ]).<br />
inference(unscan-r/2,<br />
[ nrR([-Qi|Qs]) ],<br />
nrR(Qs),<br />
[ \+ (Qi : ˜_) ]).<br />
asserts([]).<br />
asserts([nrR([-C|Cs])|L]) :- !, assert(nrR([-C|Cs])), asserts(L).<br />
asserts([_|L]) :- asserts(L).<br />
91