architxt.simplification.tree_rewriting.operations.operation

architxt.simplification.tree_rewriting.operations.operation#

Classes

Operation(*, tau, min_support, metric)

Abstract base class representing a tree rewriting operation.

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

Bases: ABC

Abstract base class representing a tree rewriting operation.

This class encapsulates the definition of operations that can be applied to a tree structure using certain equivalence subtrees, a threshold value, a minimum support value, and a metric function. It acts as the base class for any concrete operation and enforces the structure through abstract methods.

Parameters:
  • tau (float) – Threshold for subtree similarity when clustering.

  • min_support (int) – The minimum support value for a structure to be considered frequent.

  • metric (Callable[Collection[str], Collection[str], float]) – The metric function used to compute similarity between subtrees.

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

get_equiv_of(tree, *, equiv_subtrees)[source]#
Return type:

tuple[Tree, …]

property name#
Return type:

str