itacart.hierarchy.compact_cells

itacart.hierarchy.compact_cells(index)[source]

Replace exhaustive sibling sets by their parent, recursively.

Runs to a fixed point, so a fully covered base cell collapses all the way to resolution 1.

Distinct from itacart.index.normalize(). Normalization rewrites spelling and never changes the region: it collapses a complete alphabet away from the border and leaves a border-absorbing node as written, because four quaternary children spell the whole alphabet while such a parent may have five. Compaction counts the children the parent actually has, so it folds an absorbing cell exactly when all of them are present, whichever stem they are spelled under, and leaves a partition that is incomplete at the border uncompacted rather than claimed whole.

Parameters:

index (str) – Compositional index string.

Return type:

str

Returns:

The compacted index, mixed-resolution in general, with cells in deterministic order.