architxt.simplification.tree_rewriting.operations.collections

architxt.simplification.tree_rewriting.operations.collections#

Classes

FindCollectionsOperation(*args[, naming_only])

Identifies and groups nodes into collections.

class architxt.simplification.tree_rewriting.operations.collections.FindCollectionsOperation(*args, naming_only=False, **kwargs)[source]#

Bases: Operation

Identifies and groups nodes into collections.

The operation can operate in two modes: 1. Naming-only mode: Simply assigns labels to valid collections without altering the tree’s structure. 2. Structural modification mode: Groups nodes into collection sets, updates their labels, and restructures the tree by creating collection nodes.

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