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 />
7.2 Tree collecti<strong>on</strong><br />
7.2.1 Collecting trees: first idea<br />
(9) The most obvious way to collect trees is this:<br />
/* ckyCollect.pl<br />
* E Stabler, Feb 2000<br />
* collect a tree from a CKY parser chart<br />
*/<br />
:- op(1200,xfx,:˜). % this is our object language "if"<br />
:- use_module(library(lists),[member/2]).<br />
ckyCollect(Chart,N,S,S/STs) :- collectTree(Chart,0,S,N,S/STs).<br />
collectTree(Chart,I,A,J,A/Subtrees) :- member((I,A,J),Chart), (A :˜ L), collectTrees(L,Chart,I,J,Subtrees).<br />
collectTree(Chart,I,A,J,A/[]) :- member((I,A,J),Chart), $\backslash$+((A :˜ _)).<br />
collectTrees([],_,I,I,[]).<br />
collectTrees([A|As],Chart,I,J,[A/ATs|Ts]) :- collectTree(Chart,I,A,K,A/ATs), collectTrees(As,Chart,K,J,Ts).<br />
(10) With this file, we can have sessi<strong>on</strong>s like this:<br />
Process prolog finished<br />
SICStus 3.8.1 (x86-linux-glibc2.1): Sun Feb 20 14:49:19 PST 2000<br />
Licensed to humnet.ucla.edu<br />
| ?- [ckySics].<br />
{c<strong>on</strong>sulting /home/es/tex/185-00/ckySics.pl...}<br />
{c<strong>on</strong>sulted /home/es/tex/185-00/ckySics.pl in module user, 260 msec 46700 bytes}<br />
yes<br />
| ?- [ckyCollect].<br />
{c<strong>on</strong>sulting /home/es/tex/185-00/ckyCollect.pl...}<br />
{c<strong>on</strong>sulted /home/es/tex/185-00/ckyCollect.pl in module user, 20 msec 24 bytes}<br />
yes<br />
| ?- [g1].<br />
{c<strong>on</strong>sulting /home/es/tex/185-00/g1.pl...}<br />
{c<strong>on</strong>sulted /home/es/tex/185-00/g1.pl in module user, 20 msec 2816 bytes}<br />
yes<br />
| ?- [pp_tree].<br />
{c<strong>on</strong>sulting /home/es/tex/185-00/pp_tree.pl...}<br />
{c<strong>on</strong>sulted /home/es/tex/185-00/pp_tree.pl in module user, 20 msec 1344 bytes}<br />
yes<br />
| ?- computeClosure([the,idea,will,suffice],Chart),nl,ckyCollect(Chart,4,ip,T),pp_tree(T).<br />
....:.:.:.:.::.::.:.:.:.:.:.::.:<br />
ip /[<br />
dp /[<br />
d1 /[<br />
d0 /[<br />
the /[]],<br />
np /[<br />
n1 /[<br />
n0 /[<br />
idea /[]]]]]],<br />
i1 /[<br />
i0 /[<br />
will /[]],<br />
vp /[<br />
v1 /[<br />
v0 /[<br />
suffice /[]]]]]]<br />
T = ip/[dp/[d1/[d0/[the/[]],np/[n1/[...]]]],i1/[i0/[will/[]],vp/[v1/[v0/[...]]]]],<br />
Chart = [(0,d0,1),(0,d1,2),(0,dp,2),(0,ip,4),(0,the,1),(1,idea,2),(1,n0,2),(1,n1,2),(1,...,...),(...,...)|...] ? ;<br />
no<br />
| ?-<br />
(11) This works, but it makes tree collecti<strong>on</strong> almost as hard as parsing!<br />
When we are collecting the c<strong>on</strong>stituents, this collecti<strong>on</strong> strategy will sometimes follow blind alleys.<br />
110