zeroshotGPU / zsgdp /verify /coverage.py
Arjunvir Singh
Initial commit: zeroshotGPU MVP with full eval surface
db06ffa
Raw
History Blame Contribute Delete
500 Bytes
"""Coverage checks."""
from __future__ import annotations
from zsgdp.schema import PageProfile, ParsedDocument
def page_text_chars(parsed: ParsedDocument, page_num: int) -> int:
return sum(len(element.content()) for element in parsed.elements if element.page_num == page_num)
def coverage_ratio(page: PageProfile, parsed: ParsedDocument) -> float:
expected = max(page.digital_text_chars, 1)
observed = page_text_chars(parsed, page.page_num)
return min(observed / expected, 1.0)