Notes on computational linguistics.pdf - UCLA Department of ...
Notes on computational linguistics.pdf - UCLA Department of ...
Notes on computational linguistics.pdf - UCLA Department of ...
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 />
a. d<br />
e c<br />
b. d<br />
b d<br />
e c<br />
b<br />
a<br />
b<br />
a<br />
d<br />
b<br />
C<strong>on</strong>sider, for example, how we could substitute the n<strong>on</strong>-empty b <strong>of</strong> in 17a into the positi<strong>on</strong> <strong>of</strong> the<br />
empty b, obtaining the tree in 17b. This involves two basic steps. First, we must replace the n<strong>on</strong>empty<br />
subtree b/[a/[]] by an empty subtree b/[], and then we must replace the other empty subtree b/[]<br />
by b/[a/[]]. Both steps involve modifying a tree just by replacing <strong>on</strong>e <strong>of</strong> its subtrees by something<br />
else. We formalize this basic step first, as an operati<strong>on</strong> <strong>on</strong> our special notati<strong>on</strong> for nodes, with the<br />
predicate replace_node.<br />
(18) We define replace_node(A,DescA,B,DescB) to hold just in case nodes A and B are subtree isomorphic<br />
except that where the subtree <strong>of</strong> the former has descendant DescA, the latter has descendant DescB:<br />
replace_node(A, A, B, B). % A replaced by B<br />
replace_node(A, DescendantA, B, DescendantB) :- % DescA repl by DescB<br />
label(A, Label),<br />
label(B, Label),<br />
children(A, ChildrenA),<br />
children(B, ChildrenB),<br />
replace_nodes(ChildrenA, DescendantA, ChildrenB, DescendantB).<br />
The first clause, in effect, just replaces the current node A by B, while the sec<strong>on</strong>d clause uses the relati<strong>on</strong><br />
replace_nodes to do the replacement in exactly <strong>on</strong>e <strong>of</strong> the children <strong>of</strong> the current node.<br />
(19) We extend the previous relati<strong>on</strong> to node sequences:<br />
replace_nodes([A|As], DA, [B|Bs], DB) :replace_node(A,<br />
DA, B, DB),<br />
iso_subtrees(As, Bs).<br />
replace_nodes([A|As], DA, [B|Bs], DB) :iso_subtree(A,<br />
B),<br />
replace_nodes(As, DA, Bs, DB).<br />
With these axioms, we can establish some basic relati<strong>on</strong>s am<strong>on</strong>g trees. For example, with two basic<br />
replacement steps, we can transform the tree in Figure 17a into the tree in Figure 17b. The first step<br />
replaces the subtree b/[a/[]] by b/[], and the sec<strong>on</strong>d step replaces the original b/[] by b/[a/[]].<br />
C<strong>on</strong>sider the first step, and since we are working with our special node representati<strong>on</strong>s, let’s focus our<br />
attenti<strong>on</strong> just <strong>on</strong> the subtrees dominated by c, where the acti<strong>on</strong> is. Taking just this subtree, we establish<br />
a relati<strong>on</strong> between the root nodes:<br />
A=n(root,c/[b/[],d/[b/[a/[]]]],n<strong>on</strong>e),<br />
B=n(root,c/[b/[],d/[b/[]]],n<strong>on</strong>e).<br />
What we do to obtain B is to replace DescA in A by DescB, where<br />
DescA=n(1,b/[a/[]],n(2,d/[b/[a/[]]],<br />
n(root,c/[b/[],d/[b/[a/[]]]],n<strong>on</strong>e))),<br />
DescB=n(1,b/[],n(2,d/[b/[]],<br />
n(root,c/[b/[],d/[b/[]]],n<strong>on</strong>e))).<br />
We can deduce that these elements stand in the relati<strong>on</strong><br />
68