itacart.serialization.tree_blob.recompose_to_prefix_form
- itacart.serialization.tree_blob.recompose_to_prefix_form(index)[source]
Rewrite an index in canonical prefix form.
The textual counterpart of what
encode_tree()does internally: every distinct prefix appears once, siblings are ordered, and the leaf set is preserved exactly. Idempotent.One rewrite touches the leaf set, and it preserves the region. A cell written whole absorbs any descendant also written under it, as
itacart.compose()anditacart.normalize()do, soNE(0500/0300,0500/0300(1))recomposes toNE(0500/0300). The absorption is lexical, like theirs: a descendant spelled under another column’s prefix – the children a border cell fathers to the east – is not under the cell’s own spelling and stays as written, which loses nothing because both leaves are kept.This is not
itacart.normalize(), which collapses a complete sibling set into its parent. Compaction preserves coverage while changing the leaf set, and a blob’s identity is its leaf set, so the two canonical forms answer different questions and have different fixed points.- Parameters:
index (
str) – Compositional index string.- Return type:
- Returns:
The index in canonical prefix form.
- Raises:
InvalidIndexError – If the index is malformed, or if it names row 1000, which holds the polar caps: this version of the binary codecs does not serialize them.
Example
>>> recompose_to_prefix_form("NE(0625/0451(2,1))") 'NE(0625/0451(1,2))'