architxt.simplification.tree_rewriting.operations.reductions#

Classes

ReduceBottomOperation(*, tree_clusterer, ...)

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

ReduceOperation(*, tree_clusterer, min_support)

Base class for reduction operations.

ReduceTopOperation(*, tree_clusterer, ...)

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

class architxt.simplification.tree_rewriting.operations.reductions.ReduceBottomOperation(*, tree_clusterer, min_support)[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 only 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[_SubTree]

class architxt.simplification.tree_rewriting.operations.reductions.ReduceOperation(*, tree_clusterer, min_support)[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)[source]#

Apply the rewriting operation on the given tree.

Parameters:

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

Return type:

bool

Returns:

A boolean indicating whether the operation modified the tree (True) or left it unaltered (False).

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

Iterable[_SubTree]

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

Bases: ReduceOperation

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

It identifies subtrees that do not have a specific type and 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[_SubTree]