compatibleSubtrees {xegaDerivationTrees} | R Documentation |
Test the compatibility of subtrees.
Description
compatibleSubtrees()
tests the compatibility of two
subtrees.
Usage
compatibleSubtrees(n1, n2, maxdepth = 5, DepthBounded = TRUE)
Arguments
n1 |
Attributed node of the root of subtree 1. |
n2 |
Attributed node of the root of subtree 2. |
maxdepth |
Integer. Maximal derivation depth. |
DepthBounded |
|
Details
compatibleSubtrees()
tests the compatibility of two
subtrees:
The root symbol of the two subtrees must be identical:
(n1$ID==n2$ID)
.The depth restrictions must hold:
-
depth(n1) + depth(subtree2) <= maxdepth+maxSPT
-
depth(n2) + depth(subtree1) <= maxdepth+maxSPT
maxSPT is the maximal number of derivations needed to generate a complete derivation tree.
-
Value
TRUE
or FALSE
See Also
Other Tree Operations:
treeExtract()
,
treeInsert()
Examples
g<-compileBNF(booleanGrammar())
t1<-randomDerivationTree(g$Start, g)
t1anl<-treeANL(t1, g$ST)
t2<-randomDerivationTree(g$Start, g)
t2anl<-treeANL(t2, g$ST)
n1<-chooseNode(t1anl$ANL)
n2<-chooseNode(t2anl$ANL)
compatibleSubtrees(n1, n2)
compatibleSubtrees(n1, n2, maxdepth=1)
compatibleSubtrees(n1, n2, DepthBounded=FALSE)