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
  • TRUE: Only subtrees with the same root symbol and which respect the depth restrictions are compatible.

  • FALSE: The depth restrictions are not checked.

Details

compatibleSubtrees() tests the compatibility of two subtrees:

  1. The root symbol of the two subtrees must be identical: (n1$ID==n2$ID).

  2. The depth restrictions must hold:

    1. depth(n1) + depth(subtree2) <= maxdepth+maxSPT

    2. 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)


[Package xegaDerivationTrees version 1.0.0.0 Index]