Skip to main content

Parallel text extraction and processing customizable pipeline

Project description

Patee

test

TestPyPI

PyPI - Wheel PyPI - Python Version

PyPI

PyPI - Wheel PyPI - Python Version

Patee (Parallel Text Extraction and Processing Pipeline) is a Python library designed for processing and extracting text from monolingual or multilingual documents in different languages.

It provides a flexible pipeline architecture for working with multilingual content.

The library allows users to extract, align, and process text across language pairs in a structured manner.

Installation:

pip install patee

How it Works

Patee operates through a configurable pipeline system:

  1. Configuration: Pipelines are defined in YAML files (e.g., pdf.yml that specify processing steps.

  2. Source Documents: The library works with document sources such as:

    • MultilingualSingleFile: Represents a single document mixing multiple languages
    • MonolingualSingleFilePair: Pairs two documents in different languages for parallel processing
  3. Processing Flow:

    • The pipeline is initialized with a configuration file
    • Documents are loaded into the pipeline
    • Each configured step is executed sequentially
    • Processing parameters can be controlled (e.g., page ranges via PageInfo)
    • Results are collected and made available after pipeline execution
  4. Execution: The pipeline is executed via the run() method, which returns a result object indicating whether processing completed successfully.

Run modes

Patee supports two run modes:

  1. Non-persistent: All processing is done in memory, and results are not saved
result = pipeline.run(source)
  1. Persistent run: Results are saved to disk, allowing for later retrieval and analysis
result = pipeline.run(source, Path("path/to/dir"))

Available Pipeline Steps

There are two types of pipelines available in Patee:

  • Extract steps: Should be the first step in the pipeline and retrieves the initial texts pair to start the processing
  • Process steps: Process the extracted texts and can be used in any order after the first extract step

Available Extract Steps

  • text_reader_extractor: Extract text from sources in text format (e.g., TXT)
  • docling_extractor: Extracts text from different document formats using the docling library. Supported formats include PDF, DOCX, HTML and more. The full list can be found here.

Available Process Steps

  • noop_step_processor: Test step that does nothing
  • human_in_the_loop_processor: A step that requires human input to process the text

human_in_the_loop_processor details

This step only works in persistent mode. In non-persistent mode, it is ignored.

It stops the pipeline execution to perform a human revision/edition of the text.

In the first execution of the step:

  • The text of the previous step is persisted
  • A marker file is created (patee_rename_me_to_done_when_human_in_the_loop_is_done)
  • The pipeline execution is stops with a partial execution result

When the human revision is done, the user should rename the marker file to patee_done and run the pipeline again.

The pipeline will then continue from the last step.

Example Usage

Basic pipeline execution

from pathlib import Path
from patee import Patee, MonolingualSingleFilePair, MonolingualSingleFile, PageInfo

# Load the pipeline configuration from a YAML file
pipeline = Patee.load_from('pipelines/pdf.yml')

# Load a source to process
document_1 = MonolingualSingleFile(
            document_path=Path("sources/GUIA-PDDD_ES.pdf"),
            iso2_language="es",
        )
document_2 = MonolingualSingleFile(
            document_path=Path("sources/GUIA-PDDD.pdf"),
            iso2_language="ca",
        )
config = PageInfo(
            start_page=4,
            end_page=5
        )
source = MonolingualSingleFilePair(
        document_1=document_1,
        document_2=document_2,
        shared_config=config,
    )
    
# Execute the pipeline
result = pipeline.run(source)

# Check if the pipeline executed successfully
if result.completed:
    print("Pipeline executed successfully")
else:
    print("Pipeline execution failed")

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

patee-0.3.1.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

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

patee-0.3.1-py2.py3-none-any.whl (16.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file patee-0.3.1.tar.gz.

File metadata

  • Download URL: patee-0.3.1.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for patee-0.3.1.tar.gz
Algorithm Hash digest
SHA256 1d464a1d06b35fc85ef812f44b165e5d664aab8ded181b5e9a7972bd20ecb06d
MD5 a29d7230a7d63a16e3f46224c9a6ca18
BLAKE2b-256 8168466e6230297a9d20e32753de95237539812ce78b667629a24349ea3ffcd6

See more details on using hashes here.

Provenance

The following attestation bundles were made for patee-0.3.1.tar.gz:

Publisher: publish.yml on hbiarge/patee

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file patee-0.3.1-py2.py3-none-any.whl.

File metadata

  • Download URL: patee-0.3.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for patee-0.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6e3007cb14367d13c54d2b7647e1ed07fbd75a8e7cc6607fd910a5b452e6ccfb
MD5 9075368abedc4b1d9c56bda3fe25be90
BLAKE2b-256 2ff7cb11f83a3dfbe6328b105b84833a8c505cb57aee16a4caf19f105abddcfe

See more details on using hashes here.

Provenance

The following attestation bundles were made for patee-0.3.1-py2.py3-none-any.whl:

Publisher: publish.yml on hbiarge/patee

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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