architxt.simplification.tree_rewriting.operations.reductions#

Classes

ReduceBottomOperation(*, tau, min_support, ...)

Reduces the unlabelled nodes of a tree at the bottom-level.

ReduceOperation(*, tau, min_support, metric)

Base class for reduction operations.

ReduceTopOperation(*, tau, min_support, metric)

Reduces the unlabelled nodes of a tree at the top-level.

class architxt.simplification.tree_rewriting.operations.reductions.ReduceBottomOperation(*, tau, min_support, metric)[source]#

Bases: ReduceOperation

Reduces the unlabelled nodes of a tree at the bottom-level.

This function identifies subtrees that do not have a specific type but contain children of type ENT. It then repositions these subtrees’ children directly under their parent nodes, effectively “flattening” the tree structure at this level.

subtrees_to_reduce(tree)[source]#
Return type:

Iterable[Tree]

class architxt.simplification.tree_rewriting.operations.reductions.ReduceOperation(*, tau, min_support, metric)[source]#

Bases: Operation, ABC

Base class for reduction operations.

This class defines custom behavior for identifying subtrees to be reduced and applying the reduction operation.

apply(tree, *, equiv_subtrees)[source]#

Apply the rewriting operation on the given tree.

Parameters:
  • tree (Tree) – The tree to perform the reduction on.

  • equiv_subtrees (set[tuple[Tree, …]]) – The cluster of equivalent subtrees in the forest.

Return type:

tuple[Tree, bool]

Returns:

A tuple containing the transformed tree and a boolean flag. The boolean flag typically indicates whether the operation modified the tree (True) or left it unaltered (False).

abstractmethod subtrees_to_reduce(tree)[source]#
Return type:

Iterable[Tree]

class architxt.simplification.tree_rewriting.operations.reductions.ReduceTopOperation(*, tau, min_support, metric)[source]#

Bases: ReduceOperation

Reduces the unlabelled nodes of a tree at the top-level.

This function identifies subtrees that do not have a specific type but contain children of type ENT. It then repositions these subtrees’ children directly under their parent nodes, effectively “flattening” the tree structure at this level.

subtrees_to_reduce(tree)[source]#
Return type:

Iterable[Tree]