architxt.simplification.simple_rewrite#
Functions
|
Rewrite a forest into a valid schema, treating each tree as a distinct group. |
- architxt.simplification.simple_rewrite.simple_rewrite(forest, *, commit=True)[source]#
Rewrite a forest into a valid schema, treating each tree as a distinct group.
This function processes each tree in the forest, collapsing its entities into a single group node if the tree contains unlabelled nodes. Each unique combination of entity labels is assigned a consistent group ID. Duplicate entities are removed.
- Parameters:
forest (
Iterable[Tree]) – A forest to be rewritten in place.commit (
bool | int) – Commit automatically if using TreeBucket. If already in a transaction not commit is applied. - If False, no commits are made, it relies on the current transaction. - If True (default), commits in batch. - If an integer, commits every N tree. To avoid memory issues, we recommend using incremental commit with large iterables.
- Return type: