architxt.simplification.tree_rewriting.operations.relations

architxt.simplification.tree_rewriting.operations.relations#

Classes

FindRelationsOperation(*args[, naming_only])

Identifies and establishes hierarchical relationships between GROUP nodes within a tree structure.

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

Bases: Operation

Identifies and establishes hierarchical relationships between GROUP nodes within a tree structure.

The function scans for subtrees that contain at least two distinct elements. When a GROUP node is found to have a relationship with a collection, that relationship is distributed between the GROUP node itself and each member of the collection.

The operation can operate in two modes: 1. Naming-only mode: Simply assigns labels to valid relations without altering the tree’s structure. 2. Structural modification mode: restructures the tree by creating relation nodes between groups and collections.

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