Skip to main content

DocForest

DocForest is a Python library for intelligently chunking structured documents like Markdown and AsciiDoc. It organizes document content into a recursive, tree-like structure, ensuring that each chunk retains its full contextual path from its parent headings. This makes it an ideal tool for RAG (Retrieval-Augmented Generation) systems, semantic search, and other NLP tasks.


Features

  • Hierarchical Chunking: Splits documents based on heading levels, preserving the logical structure.
  • Context Preservation: Each section's content is linked to all its parent headings, providing rich context.
  • Flexible Output: Generates a structured "forest" or "tree" that is easy to traverse and process.
  • Support for Multiple Formats: Built to handle various structured document types.

Installation

Install docforest from PyPI:

pip install docforest

Usage

from docforest import DocForest, DocStyle

# Create a DocForest instance with the desired document style
forest = DocForest(style=DocStyle.MARKDOWN)

# chunk a document by giving its content
forest.chunk(content="content")

License

This project is licensed under the MIT License. See the LICENSE file for details.

Metadata

Release files for docforest 0.1.1

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

Source distribution (sdist)

Source distribution for docforest 0.1.1
File Size Uploaded
docforest-0.1.1.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for docforest 0.1.1
File Interpreter ABI Platform
docforest-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 8.1 kB

Release files / docforest-0.1.1.tar.gz

Download URL docforest-0.1.1.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ab23deb66f3921989ad1a487663aebd1f23dc46c99c39eaa4499dd1d3a82c1af
BLAKE2b-256 checksum
How to use checksums
ea659046a60d27a9e4e7956d4cf6439263698a66ded4c55e9684390df4940606
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / docforest-0.1.1-py3-none-any.whl

Download URL docforest-0.1.1-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c77dc1da4583f35ef84835ea602f7f165db5da97b8adf866cdfb51ad9d3ec1f2
BLAKE2b-256 checksum
How to use checksums
a310978d0558d2020dbb335bdb6bef3c27df32d124c0c9891d316f9b832831c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

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