Skip to main content

A specialized document chunking library for complex document structures

Project description

DocChunker

A specialized document chunking library designed to handle complex document structures in DOCX and PDF files. DocChunker intelligently processes structured documents containing tables, nested lists, images, and other complex elements to create semantically meaningful chunks that preserve context.

Key Features

  • Advanced DOCX Parsing: Handles complex elements like nested lists and tables with merged cells.
  • Contextual Chunking: Preserves document hierarchy (headings, etc.) within chunks.
  • Configurable Strategy: Tune chunk size (tokens) and element-based overlap.
  • Semantic Cohesion: Aims to keep related content (list items, table rows) together.
  • RAG-Optimized: Produces chunks ideal for effective information retrieval.

Installation

DocChunker requires Python 3.9+ and is best installed using uv, a fast Python package installer and resolver.

# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate

# Install with uv
uv pip install -r requirements.txt

Quick Start

from docchunker import DocChunker

# Initialize the chunker with desired settings
chunker = DocChunker(chunk_size=200)

# Process a document
chunks = chunker.process_document("complex_document.docx")

# Work with chunks
for i, chunk in enumerate(chunks):
    print(f"Chunk {i}: {chunk.metadata['type']} - {len(chunk.text)} chars")

RAG DEMO

For an end-to-end example of building a simple RAG system using DocChunker with LangChain, check out the examples/RAG_demo.ipynb notebook.

Development

To contribute to DocChunker:

# Clone the repository
git clone https://github.com/vladGriguta/DocChunker
cd docchunker

# Set up development environment
python -m venv .venv
source .venv/bin/activate
uv pip install -e ".[dev]"

# Run tests
pytest

Future Roadmap

  • Chunk Size Homogenization: Implement strategies to reduce chunk size variance.
  • Langchain RAG Examples: Provide integration guides for Langchain.
  • Enhanced Unit Testing: Add more tests for complex tables and lists.
  • Retrieval Evaluation Framework: Develop a framework to assess chunk effectiveness.
  • Increased Test Coverage: Systematically improve overall code coverage.
  • PDF Support: Extend parsing and chunking to PDF documents.
  • Advanced Element Handling: Support for images (captions/alt-text), headers/footers, footnotes.
  • Performance Optimizations: Profile and optimize for very large documents.

License

MIT

About the Author

DocChunker is developed by Vlad Griguta. Connect with me on LinkedIn or GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docchunker-0.1.3.tar.gz (1.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docchunker-0.1.3-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file docchunker-0.1.3.tar.gz.

File metadata

  • Download URL: docchunker-0.1.3.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for docchunker-0.1.3.tar.gz
Algorithm Hash digest
SHA256 c6fa35e83e02b5d3930dd41e7261a546979937e38cababb8cf0c541b9e322605
MD5 d2f7178cdb503cf7eaa59a93f2abf427
BLAKE2b-256 c89ca66cbe470ea48083b57344ba8f95401149175d8a188154ce3ac25ebae12f

See more details on using hashes here.

File details

Details for the file docchunker-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: docchunker-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for docchunker-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9c8ad2a266ea1e2090e000dc5109a8b6b35c063a3a6cc9507062b3916f83879c
MD5 785f056081dcbfdf971fcc79b422c4ff
BLAKE2b-256 f00fe2ef033ab17c4d5c61981a26024cfcce1a70f8c4da5da29c0804fa0ffdb3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page