DSTPR: Domain-specific Text Pre-processing and Ranking
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:
- Heuristic Cleansing & Tokenization: Breaks unformatted text, inline bullets, and run-on paragraphs into clean lines. Also applies pre-compiled regex stop phrase searches.
- Contrastive Margin Ranking: Computes relative margin scores combined with syntactic keyword augmentation.
- Cross-Encoder Ranking: Routes only borderline sentences through a cross-encoder supported by profile-defined anchors, avoiding false negatives.
- Document-Level Adaptive Rescue: Prevents empty document outputs by adaptively rescuing the highest-scoring contrastive sentences in their original document.
- Parallel Execution: Overlaps CPU tokenization with GPU compute via background execution pools.
Installation
To install the package, simply run
pip install dstpr
To initialize models and download required linguistic resource dependencies:
from dstpr.utils.setup import setup_resources
setup_resources()
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,
doc_chunk_size=100,
use_gpu=True
)
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 toward0.6, for example, ensures only stronger matching sentences are passed through. Lowering it toward0.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:
python -m dstpr.utils.cli
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.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dstpr-0.4.1.tar.gz | 16.5 kB | Without provenance | Details for dstpr-0.4.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dstpr-0.4.1-py3-none-any.whl | Python 3 | none | any | Details for dstpr-0.4.1-py3-none-any.whl |
Total release size: 33.7 kB
Release files / dstpr-0.4.1.tar.gz
| Download URL | dstpr-0.4.1.tar.gz |
|---|---|
| Size | 16.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5d7019db2532f38a8799711e80bab28b48a87338f0c4d51c9b6e2f731ca102df
|
|
BLAKE2b-256 checksum How to use checksums |
646360e9df3125304ca6cf828c302b89c0a0e2405542e29b81257b6952be610b
|
| 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.4.1-py3-none-any.whl
| Download URL | dstpr-0.4.1-py3-none-any.whl |
|---|---|
| Size | 17.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7dc24fb6c13a7c3292de53f15c171a3a4ac06a8ebaf2bd69eed8ec985d9dac93
|
|
BLAKE2b-256 checksum How to use checksums |
69f0c1e53a6ae98175bedb643860e039af9cb3f687cd9dfe9672f9c8d5d35af3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|
Security for dstpr 0.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.