Skip to main content

sayou-document

PyPI version License Docs

Overview

The Universal Document Parsing Gateway for Sayou Fabric.

sayou-document is a high-fidelity parsing engine that converts diverse document formats (PDF, DOCX, PPTX, XLSX, Images) into a unified, structured Document Object Model (DOM).

Unlike simple text extractors, it preserves the semantic structure of documents—headers, tables, charts, and layout coordinates—making it ideal for RAG applications that require layout awareness.


1. Architecture & Role

The Document engine acts as a normalizer. It accepts raw file bytes and applies the optimal Parser Strategy to output a structured SayouDocument.

graph LR
    File[Raw File] --> Pipeline[Document Pipeline]
    
    subgraph Parsers
        PDF[PDF Parser + OCR]
        Office[Office Parser]
        Img[Image Converter]
    end
    
    Pipeline -->|Type Detection| Parsers
    Parsers --> DOM[Structured DOM]

1.1. Core Features

  • Smart Routing: Automatically detects file types (signatures) and selects the best parser.
  • Hybrid Extraction: Combines native text extraction for digital PDFs with OCR fallback for scanned images.
  • Strict Schema: Outputs a standardized hierarchy (Document > Page > Element) regardless of input format.

2. Supported Formats

sayou-document supports the following file types out-of-the-box.

Format Strategy Key Description
PDF pdf Extracts text, images, and TOC using PyMuPDF. Supports OCR.
Word docx Parses DOCX files, preserving heading levels and lists.
PowerPoint pptx Extracts text frames, speaker notes, and tables from slides.
Excel xlsx Converts sheets into table elements and extracts embedded charts.
Image image Auto-converts JPG/PNG/TIFF to PDF, then applies OCR.

3. Installation

pip install sayou-document

# For OCR support (requires Tesseract installed on OS)
pip install "sayou-document[ocr]"

4. Usage

The DocumentPipeline orchestrates file detection and parsing. It standardizes the input via the process method.

Case A: PDF Parsing (Standard)

Processes a PDF file to extract structured text and layout info.

import os
from sayou.document import DocumentPipeline

file_path = "quarterly_report.pdf"
with open(file_path, "rb") as f:
    file_bytes = f.read()

doc = DocumentPipeline.process(
    data=file_bytes,
    metadata={"filename": os.path.basename(file_path)}
)

# 4. Result
print(f"File: {doc.file_name}, Pages: {doc.page_count}")
print(f"First Element: {doc.pages[0].elements[0].text}")

Case B: Office Documents (Word/Excel)

Parses Office formats while preserving table structures.

from sayou.document import DocumentPipeline

with open("salary_table.xlsx", "rb") as f:
    file_bytes = f.read()

doc = DocumentPipeline.process(
    data=file_bytes,
    metadata={"filename": "salary_table.xlsx"}
)

# Access tables
tables = [e for p in doc.pages for e in p.elements if e.category == "table"]
print(f"Extracted {len(tables)} tables.")

Case C: Image with OCR

Automatically handles image conversion and OCR processing.

from sayou.document import DocumentPipeline

# Initialize with OCR enabled
pipeline = DocumentPipeline(config={"use_ocr": True, "ocr_lang": "eng"})

with open("scanned_receipt.png", "rb") as f:
    file_bytes = f.read()

doc = pipeline.process(
    data=file_bytes,
    metadata={"filename": "scanned_receipt.png"}
)

print(f"OCR Result: {doc.pages[0].elements[0].text}")

5. Configuration Keys

Customize the parsing behavior via the config dictionary.

  • use_ocr: (bool) Enable OCR for scanned pages or images.
  • ocr_lang: (str) Tesseract language code (default: eng+kor).
  • extract_images: (bool) Whether to extract embedded images to disk.
  • table_strategy: (str) fast (text-based) or accurate (vision-based).

6. License

Apache 2.0 License © 2026 Sayouzone

7. Plugin List

Plugin Example Description
Docx Parser ▶
Excel Parser ▶
PPTX Parser ▶
PDF Parser ▶

Metadata

Release files for sayou-document 0.5.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sayou-document 0.5.2
File Size Uploaded Provenance
sayou_document-0.5.2.tar.gz 60.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sayou-document 0.5.2
File Interpreter ABI Platform
sayou_document-0.5.2-py3-none-any.whl Python 3 none any Details

Total release size: 106.9 kB

Release files / sayou_document-0.5.2.tar.gz

Download URL sayou_document-0.5.2.tar.gz
Size 60.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6dab15d8b19843a7349f29c392918f706c0d98dfa99952e5537e79c3a7e44b6c
BLAKE2b-256 checksum
How to use checksums
d3f9486b6c261e15e0ef0e0d12671907d5842fb0016d665c9db829b1416c672d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / sayou_document-0.5.2-py3-none-any.whl

Download URL sayou_document-0.5.2-py3-none-any.whl
Size 46.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
607e05c99780f0699449a9f0f61667959d61ae2c94c77cf11948802e99fea37a
BLAKE2b-256 checksum
How to use checksums
f47324b6a2ecad95f8fa83599bb3bf53966c38476a9220ad6a1b92aa8e247cd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Security for sayou-document 0.5.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page