sungguk's picture
Release visual answerability benchmark v1.0.0
e1ced61 verified
Raw History Blame Contribute Delete
931 Bytes
"""Text manifest — every rendered glyph linked to a semantic node (§9, P6).
The P6 gate "every text glyph is linked to semantic node" is enforced here: a
:class:`GlyphRecord` cannot be constructed without a ``node_id``, and
:func:`link_verdict` flags any record missing one. Kind-specific renderers build
records during their draw pass (a point label → the point id, a series label →
the series id, a tick label → a synthetic axis node, an angle measure → the
angle entity), and :func:`renderers.base.build_text_manifest` serializes them.
"""
from __future__ import annotations
from collections.abc import Sequence
from .base import GlyphRecord
def link_verdict(glyphs: Sequence[GlyphRecord]) -> tuple[bool, list[int]]:
"""``(all_linked, bad_indices)`` — every glyph must carry a node id."""
bad = [i for i, g in enumerate(glyphs) if not g.node_id]
return (not bad, bad)
__all__ = ["link_verdict"]