Spanwatch

•

Reconstructs the human reading order of a laid-out document from text block bounding boxes, ensuring a deterministic fallback when language models are unavailable.

Spanwatch is a robust document AI tool designed to accurately reconstruct the reading order of text blocks within laid-out documents. Unlike simple sorting methods, it employs a sophisticated recursive XY-cut algorithm to understand complex page structures, such as multi-column layouts and headers. While it can optionally integrate with language models for refined ordering, its core geometric computation guarantees a deterministic and reliable result even without any model, API key, or network access. This ensures consistent performance and provides a crucial fallback mechanism for document processing pipelines, recording which method was used for auditability.

Características Principales

01Model Context Protocol (MCP) Server: Exposes its functionality as an MCP server over stdio, enabling easy integration into AI orchestration systems.
02Deterministic Reading Order: Computes reading order geometrically using recursive XY-cut, operating without models, API keys, or network access.
03Optional LLM Refinement: Allows seamless integration with language models (e.g., Anthropic) to refine the geometrically derived order, with robust validation and automatic fallback on failure.
04Input Validation & Resource Limits: Enforces configurable limits on pages and blocks per page to prevent memory exhaustion and handle oversized or untrusted input gracefully.
05Flexible Deployment: Available as a command-line tool for one-off processing and a Python library for programmatic integration.
060 GitHub stars

Casos de Uso

01Building resilient document AI pipelines that require a dependable reading order service with or without external AI models.
02Automating text extraction and processing from diverse document layouts like research papers, reports, or newsletters.
03Developing applications that need to logically sequence content blocks from OCR or PDF parsing results for further analysis.