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.4.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.4-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: docchunker-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 ea20b0f9ef3cb4bf2054e9f96e6e6d15f7c3c2a18c5bff91cf5a7590d8395697
MD5 2b488dd116b3a05454fc7db49d2c04c9
BLAKE2b-256 d7eb371a27aed6704375b19d25035607debf1f6c403c199ae6dbdda55bd096e9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: docchunker-0.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 835b10d6452ec579b1ece362b465200ea3e774d033ec7487c9570e61dd1377c9
MD5 8c35522bc4590f2bd26d70dacc2af9cc
BLAKE2b-256 c66127426cfeb92eba882788bfdc05be85204fb0a3d4efcabd020be983e9c14a

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