In a multi-stage H-Net each router only sees the output of the stage before it, so a stage-1 boundary index counts stage-0 chunks, not bytes. To read boundaries, or to report the paper's bytes per innermost chunk (BPIC), you have to map them back. Then you can compare them with SpaceByte's heuristic.
chunk_positions(stage_masks)
stage_masks[0] is a boolean tensor over the bytes. stage_masks[s] is a boolean tensor over the positions kept by stage s - 1. Raise ValueError if a mask's length does not match the number of positions kept before it.ints in increasing order.bytes_per_chunk(stage_masks)
is_spacelike(byte)
byte is an int in 0..255. Return True unless it encodes an ASCII letter, an ASCII digit or a UTF-8 continuation byte (0x80 to 0xBF). Lead bytes of multi-byte characters are therefore spacelike.spacebyte_positions(data)
data is a bytes object. Return the list of positions kept by SpaceByte's rule: position 0 always, and any spacelike byte whose previous byte is not spacelike.boundary_overlap(positions, data)
(precision, recall) as floats: precision is the fraction of positions that are in spacebyte_positions(data), recall is the fraction of spacebyte_positions(data) found in positions. Use 0.0 for a precision with empty positions.bytes object in Python yields integers.