Delver is a tool for declarative PDF extraction
Project description
Delver
A high-performance, declarative tool for parsing and splitting unstructured documents, with an initial focus on scanned PDF files (without OCR). This tool allows users to define custom parsing logic using a simple templating system, processing raw file bytes to produce structured outputs.
Table of Contents
- Introduction
- Motivation
- Goals
- Features
- Using DocQL
- Technical Details
- Technical Choices
- Dependencies
- Future Enhancements
- Contributing
- License
Introduction
Processing unstructured data poses significant challenges due to the lack of inherent structure and metadata. Delver is an engine for DocQL, a declarative query language for semantic extraction from unstructured documents. Inspired by the principles of SQL and DOM parsing, Delver/DocQL enables users to define semantic patterns and relationships between elements, making document parsing intuitive, modular, and scalable.
Motivation
- Complexity of Unstructured Data: Handling unstructured documents requires more than simple pattern matching.
- Need for Performance: Processing large volumes of data necessitates a high-performance solution.
- Flexibility: Users require a tool that can be customized to their specific parsing needs.
- Semantic Understanding: Focusing on the semantics of document elements can greatly improve parsing accuracy.
Goals
- Define a structured query language (DocQL) for extracting meaningful sections and content from raw documents.
- Replace brittle heuristics with composable, testable semantic match rules.
- Allow hierarchical expressions to traverse and segment documents with awareness of layout and semantics
- Support multiple matching techniques like string similarity, cosine similarity.
- Ensure high performance through efficient implementation in Rust.
- Offer optional integration with local and remote machine learning models and GPU resources.
Features
- DocQL Syntax: Express powerful hierarchical match logic using a custom declarative language inspired by SQL and HTML.
- DOM Construction: Build a logical document tree from raw elements using semantic and layout-based queries.
- Search Index: search over text and image metrics, spatial properties, document metadata (ref counts, annotations)
- High Performance: Built in Rust for speed and efficiency, suitable for processing large documents.
- Extensible Architecture: Supports integration with machine learning models as optional extras.
- Document Viewer: View and annotate Delver outputs
- Tracing: OpenTelemetry tracing for Delver engine pipeline
- Python Bindings: Accessible from Python via PyO3 bindings for easy integration into existing workflows.
Using DocQL
DocQL enables structured queries over document layout, allowing you to define how sections, tables, and text blocks should be matched and transformed.
DocQL Syntax
DocQL supports a tree-based syntax where sections and elements are matched based on text, font, layout metadata, or model-based classification. Blocks can be nested, and additional attributes control chunking and model routing.
Parameters
match: Defines what to match in the document.as: Assigns a label to the matched content for metadata.chunk_size: Specifies the size of each text chunk in tokens.chunk_overlap: Specifies the number of overlapping tokens between chunks.add_meta: Adds metadata to each chunk.model: Specifies a machine learning model to process the matched content.fuzziness: (Optional) Sets the Levenshtein distance for fuzzy matching.
Examples
Example 1: Splitting Text Between Headings
Section(match="Section 1: Management Discussion & Analysis", as="section1") {
Section(match="Section 1.1: Risks", as="section1_1") {
Section(match="Section 1.1b: Fiscal Risks", as="section1_1b") {
TextChunk(
chunkSize=500,
chunkOverlap=150,
addMeta=[section1, section1_1, section1_1b]
)
}
}
}
This template will:
- Identify the section starting with "About Me" and label it as
mysection. - Split all the text between the "About Me" heading and the "My Projects" heading into chunks of 500 tokens, overlapping by 150 tokens.
- Add the
mysectionmetadata to each chunk.
Technical Details
Architecture Overview
The system is composed of layered stages: parsing DocQL templates, matching document nodes to build a semantic DOM, and executing transformations or model inferences on matched content.
Key Components
Template Parser
- Function: Parses the user-defined templates into executable parsing instructions.
- Implementation: Uses Rust parser combinator crates like
Nomorwinnowfor efficient parsing.
Document Processor
- Function: Processes the document according to the parsing instructions, extracting and transforming content.
- Implementation: Utilizes
lopdffor low-level PDF parsing and manipulation.
Semantic Matcher
- Function: Identifies document elements based on semantic patterns (e.g., headings, tables).
- Implementation: Analyzes document structure and metadata.
Fuzzy Matcher
- Function: Performs approximate string matching to handle text variations and typos.
- Implementation: Uses algorithms like Levenshtein distance.
Tokenization Module
- Function: Tokenizes text content for chunking operations.
- Implementation: Integrates with the
tokenizersRust crate for efficient tokenization.
Machine Learning Integration
- Function: Processes matched content using specified machine learning models.
- Implementation: Provides interfaces for optional model invocation, keeping dependencies modular.
Python Bindings
- Function: Exposes core functionalities to Python applications.
- Implementation: Uses
PyO3to generate Python bindings.
Technical Choices
- Language: Rust for core implementation to ensure performance and safety.
- Template Parsing: Parser combinator crates (
Nomorwinnow) for flexible and efficient DSL parsing. - PDF Manipulation:
lopdfcrate for low-level PDF access. - Tokenization:
tokenizerscrate for efficient and customizable tokenization. - Fuzzy Matching: Implementing Levenshtein distance algorithms for approximate matching.
- Python Bindings:
PyO3to facilitate integration with Python ecosystems. - Modularity: Optional dependencies for machine learning models and GPU resources.
Dependencies
- Rust Crates:
lopdffor PDF manipulation.tokenizersfor text tokenization.pestfor parsing the template DSL.PyO3for Python bindings.
- Optional:
- Machine learning models (e.g., vision-language models).
- GPU libraries for hardware acceleration.
Future Enhancements
- OCR Support: Incorporate OCR capabilities to extract text from scanned images.
- Advanced DocQL Features: Expand the expressiveness of the query language to support joins, negations, and layout-based conditions.
- GUI Development: Create a user-friendly graphical interface for defining templates.
- Support for More Formats: Extend support to additional document formats (e.g., DOCX, HTML).
- Cloud Integration: Offer cloud-based processing options for scalability.
- Advanced NLP Features: Integrate natural language processing techniques for better semantic understanding.
- Model Training: Train model on index features to enhance matching
Contributing
Contributions are welcome! Please feel free to submit issues, fork the repository, and open pull requests.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Note: This README.md serves as both a design document and a product requirements document (PRD) for the Unstructured Data Splitter tool. It outlines the project's goals, features, technical implementation, and future plans, providing a comprehensive overview for developers and users alike.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file delver_pdf-0.1.0.tar.gz.
File metadata
- Download URL: delver_pdf-0.1.0.tar.gz
- Upload date:
- Size: 8.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aae74788f7e52f5262f31bb10a8ea29475cdcde14e60762ef86dd9ba881c2dfc
|
|
| MD5 |
53ed96bf717179174f4974f28645301b
|
|
| BLAKE2b-256 |
bf6622f63b33c2dbdcf0ebfef217fefd0ba61132ee58dff15e0e18af810f754a
|
File details
Details for the file delver_pdf-0.1.0-py3-none-win_amd64.whl.
File metadata
- Download URL: delver_pdf-0.1.0-py3-none-win_amd64.whl
- Upload date:
- Size: 65.2 kB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38b3ed8a13f0511e18e2bd3358b2c150b8f291b588e44287ee9e836c041e2daa
|
|
| MD5 |
a895c1cbbce8b2f843efe4cb6e067921
|
|
| BLAKE2b-256 |
15f716f681ce128b56af0a8cada7c9dc409bfd203a2f9e6df499fda2de967f15
|
File details
Details for the file delver_pdf-0.1.0-py3-none-win32.whl.
File metadata
- Download URL: delver_pdf-0.1.0-py3-none-win32.whl
- Upload date:
- Size: 62.9 kB
- Tags: Python 3, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ea32d708349c002956aae9ebaa541f6541c96211792a6e65720d475c630f5fe
|
|
| MD5 |
43c9e9ef1a9b50e09f1dabf649b8e320
|
|
| BLAKE2b-256 |
ff396ebd26bcf8c57b49194934a8191b6b26e8bf037852154f907853e55e5922
|
File details
Details for the file delver_pdf-0.1.0-py3-none-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: delver_pdf-0.1.0-py3-none-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 63.1 kB
- Tags: Python 3, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d593278a225d6e2c5c389ceeef0f89f4e53014124cc1f245ab84d8fa55194703
|
|
| MD5 |
4e852d82193ca6bb2d5053c9077e4420
|
|
| BLAKE2b-256 |
269945463fb9708163bbe48917b4c4c61997a3a2b48ba55a08171aa2c0d90164
|
File details
Details for the file delver_pdf-0.1.0-py3-none-musllinux_1_2_i686.whl.
File metadata
- Download URL: delver_pdf-0.1.0-py3-none-musllinux_1_2_i686.whl
- Upload date:
- Size: 193.2 kB
- Tags: Python 3, musllinux: musl 1.2+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5669e29fd071f26c7060bf576f5750d869ea4b2b43efed2be100a02c0adf70a
|
|
| MD5 |
f36e728d38ff98d8b6590e0d3896a1e9
|
|
| BLAKE2b-256 |
11606c13c6ff5e60dbe1b740da13027d867b09582a5aff20e7ff3f65466bbbef
|
File details
Details for the file delver_pdf-0.1.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl.
File metadata
- Download URL: delver_pdf-0.1.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 217.8 kB
- Tags: Python 3, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7da9f68cb15443923698c0db5576f0ee5f29c213e290967b7dd5aa5a75040536
|
|
| MD5 |
6156f839d4f31c2f046b1538c0545fd3
|
|
| BLAKE2b-256 |
43c15ee022a89838f75a45b62713b9cc5136266828e7869c73b30c0728570701
|
File details
Details for the file delver_pdf-0.1.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.
File metadata
- Download URL: delver_pdf-0.1.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 312.5 kB
- Tags: Python 3, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5899431e4e3c2f1e36a30d0784e42cd088f5e54e1e5b7fcc47dc17eb0dab5867
|
|
| MD5 |
affc8e370bd130056169877308cde4b1
|
|
| BLAKE2b-256 |
982eb8c6d4a69952e45438d21b9e1bdc9b75a9655c69695c2ac0a033e71019a1
|
File details
Details for the file delver_pdf-0.1.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl.
File metadata
- Download URL: delver_pdf-0.1.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0af7cb819e2f1a2c5657a078988c4d524cc3775234d3588e9e9b30d398a1460
|
|
| MD5 |
75ec1316a2067705967da96215c4b46c
|
|
| BLAKE2b-256 |
27ae30280a6c2ed9f765bcce66ea633146fbb0a47adc2b3930b29c26a8e74a1d
|
File details
Details for the file delver_pdf-0.1.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl.
File metadata
- Download URL: delver_pdf-0.1.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3, manylinux: glibc 2.5+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50875d19673e02600d7f2f739597af300db42ee82bc2f4a63808dfaefacf7b91
|
|
| MD5 |
89f7775b35964686736e51b2b01b4d38
|
|
| BLAKE2b-256 |
ec45b3977f082fbe011453f4e1b5104db00bb6fe969ecadb41dd8fee5572c7cb
|
File details
Details for the file delver_pdf-0.1.0-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: delver_pdf-0.1.0-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a6e2dfbed11ddc5f4dab05769fe25a037aac7c6306e99b2e1cd61055f78ab1b
|
|
| MD5 |
1604429e9d3e9a86cb30603b735ae115
|
|
| BLAKE2b-256 |
ed8e891e15801281ef40ffbb64661647ae21fd63c0068c7dd9a2176d500f9ffd
|
File details
Details for the file delver_pdf-0.1.0-py3-none-macosx_10_12_x86_64.whl.
File metadata
- Download URL: delver_pdf-0.1.0-py3-none-macosx_10_12_x86_64.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ae15223f2b2af4ecde1f0c733a84a1df019dc9f967bcd3c22f12c5f23c0728d
|
|
| MD5 |
db1abcf359b93339b0824736fde7e4ea
|
|
| BLAKE2b-256 |
749031d69f6bf1c9128132cfcd9ed7d6d826c779c8c1b43011f84234535b633a
|