Skip to main content

DSTPR: Domain-specific Text Pre-processing and Ranking

PyPI version

A high-throughput text preprocessing pipeline designed to filter, segment, and rank core sentences from noisy, plaintext documents.

This package strips away boilerplate, disclaimers, and application instructions before moving this data onto to heavier processing pipelines.


Pipeline Architecture

Instead of running heavy transformer models over every sentence in a document, DSTPR pipes documents through progressively stricter layers:

  1. Heuristic Cleansing & Tokenization: Uses PySBD (Python Sentence Boundary Disambiguation) paired with regular expressions to fix punctuation caused by flattening, then filters out sentences containing stop phrases.
  2. Semantic Section Routing: Utilizes a lightweight encoder (Default: all-MiniLM-L6-v2) to dynamically find structural transitions (i.e., headers) in input texts.
  3. Hybrid Ranking: Scores remaining sentences using a combination of Semantics (cosine similarity to anchors) and Lexical Syntax (regex- and POS-supported detection).
  4. Parallel Execution Engine: Wraps the entire pipeline inside efficient datasets to allow for batch processing at scale, with CPU or GPU.

Installation

To install the package, simply run

pip install dstpr

Usage

High-Throughput Batch Processing

This is the recommended approach for large-scale data pipelines.

from dstpr import ParallelPreprocessingPipeline, JOB_POSTING_PROFILE

pipeline = ParallelPreprocessingPipeline(profile=JOB_POSTING_PROFILE)

raw_documents = [
    "DOC 1",
    "DOC 2",
    "..."
]

cleaned_documents = pipeline.process(raw_documents, threshold=0.25)

Parameter Tuning

To adjust the trade-off between strict filtering and execution speed, consider tweaking these variables in ParallelPreprocessingPipeline:

  • threshold (Default: 0.4): Controls how aggressively sentences are discarded. Raising this value toward 0.6, for example, ensures only stronger matching sentences are passed through. Lowering it toward 0.3, on the other hand, acts as a wider net.

Creating Custom Domain Profiles (via the provided wizard)

A DomainProfile is required to use DSTPR (see the usage example). Out of the box, dstpr ships with pre-configured configurations for job postings (JOB_POSTINGS_PROFILE). However, you can easily generate an domain-specific pipeline for any specific domain using our built-in interactive configuration wizard.

To spin up the profile creation walkthrough, simply open your terminal and run:

task-profile-wizard

All profiles generated via the terminal wizard are automatically validated and written out as JSON to a local cache: ~/.config/dstpr/profiles/

Metadata

Release files for dstpr 0.2.5

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

Source distribution (sdist)

Source distribution for dstpr 0.2.5
File Size Uploaded
dstpr-0.2.5.tar.gz 16.6 kB Details

Built distribution (wheel)

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

Total release size: 34.4 kB

Release files / dstpr-0.2.5.tar.gz

Download URL dstpr-0.2.5.tar.gz
Size 16.6 kB
Tags Source
SHA-256 checksum
How to use checksums
980c2f74b5047d514eeac6f8c940af21475cb1bd344e2f42413baf776092c39e
BLAKE2b-256 checksum
How to use checksums
f7efa8c23f2d0c19363f870eca63633f55b57cfbbcd3bf2b6b7cc380853cef08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.20

Release files / dstpr-0.2.5-py3-none-any.whl

Download URL dstpr-0.2.5-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a1757b3828450429dd338ee80fb6cd37e14a3f717d2d4b3d440b128e47ec9fbd
BLAKE2b-256 checksum
How to use checksums
e4f0aed58f7f98a23e55d546bd989553476cb3112a8e8a2ba769f4a81ece50a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.20

Release history Release notifications | RSS feed

0.3.1

2 release files

This release

0.2.5 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

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