INNER CODE UNIT · Python

prose_block_before

gokayfem/awesome-vlm-architectures · scripts/extract_architecture_figures.py:79

def prose_block_before(
    page: fitz.Page, caption: fitz.Rect, x_clip: fitz.Rect
) -> fitz.Rect | None:
    candidates = []
    for block in page.get_text("blocks", sort=True):
        rect = fitz.Rect(block[:4])
        text = re.sub(r"\s+", " ", block[4]).strip()
        overlap = max(0.0, min(rect.x1, x_clip.x1) - max(rect.x0, x_clip.x0))
        if (
            rect.y1 < caption.y0 - 14
            and overlap > min(rect.width, x_clip.width) * 0.45
            and len(text) > 180
            and len(text.split()) > 28
        ):
            candidates.append(rect)
    return max(candidates, key=lambda rect: rect.y1) if candidates else None

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…