Parse client is a library to interact with OneOffTech Parse service. OneOffTech Parse is designed to extract text from PDF files preserving the structure of the document to improve interaction with Large Language Models (LLMs).
OneOffTech Parse is based on PDF Text extractor. The client is suitable to connect to self-hosted versions of the PDF Text extractor.
Note
The Parse client package is under development and is not ready for production use.
You can install the package via Composer:
composer require oneofftech/parse-client
The Parse client is able to connect to self-hosted instances of the PDF Text extractor service or the cloud hosted OneOffTech Parse service.
Before proceeding a running instance of the PDF Text extractor is required. Once you have a running instance, you can instantiate the connector by passing the url that the extractor service is listening on.
use OneOffTech\Parse\Client\Connectors\ParseConnector;
$client = new ParseConnector(baseUrl: "http://localhost:5000");
/** @var \OneOffTech\Parse\Client\Dto\DocumentDto */
$document = $client->parse("https://domain.internal/document.pdf");
Note
- The URL of the document must be accessible without authentication.
- Documents are downloaded for the time of processing and then the file is immediately deleted.
Important
The cloud hosted service is currently in private beta. Drop us a message.
Go to parse.oneofftech.de and obtain an access token. Instantiate the client and provide a URL of a PDF document.
use OneOffTech\Parse\Client\Connectors\ParseConnector;
$client = new ParseConnector("token");
/** @var \OneOffTech\Parse\Client\Dto\DocumentDto */
$document = $client->parse("https://domain.internal/document.pdf");
Note
- The URL of the document must be accessible without authentication.
- Documents are downloaded for the time of processing and then the file is immediately deleted.
Parse service supports different processors, pymupdf
or pdfact
. You can specify the preferred processor for each request.
use OneOffTech\Parse\Client\ParseOption;
use OneOffTech\Parse\Client\DocumentProcessor;
use OneOffTech\Parse\Client\Connectors\ParseConnector;
$client = new ParseConnector("token");
/** @var \OneOffTech\Parse\Client\Dto\DocumentDto */
$document = $client->parse(
url: "https://domain.internal/document.pdf",
options: new ParseOption(DocumentProcessor::PYMUPDF)
);
PDFAct offers more flexibility than PyMuPDF. You should evaluate the extraction method best suitable for your application. Here is a small comparison of the two methods.
feature | PDFAct | PyMuPDF |
---|---|---|
Text extraction | ✅ | ✅ |
Pagination | ✅ | ✅ |
Headings identification | ✅ | - |
Text styles (e.g. bold or italic) | ✅ | - |
Page header | ✅ | - |
Page footer | ✅ | - |
Parse is designed to preserve the document's structure hence the content is returned in a hierarchical fashion.
Document
├─Page
│ ├─Text (category: heading)
│ └─Text (category: body)
└─Page
├─Text (category: heading)
└─Text (category: body)
For a more in-depth explanation of the structure see Parse Document Model.
Parse client is tested using PEST. Tests run for each commit and pull request.
To execute the test suite run:
composer test
Please see CHANGELOG for more information on what has changed recently.
Thank you for considering contributing to the Parse client! The contribution guide can be found in the CONTRIBUTING.md file.
Please review our security policy on how to report security vulnerabilities.
The project is provided and supported by OneOff-Tech (UG).
The MIT License (MIT). Please see License File for more information.