Skip to main content

PorosData-Processor

Python Version License: CC BY 4.0

PorosData-Processor cleans MinerU-derived scientific document text for downstream LLM and data-mining workflows. It normalizes text without breaking LaTeX formulas, repairs OCR errors, cleans up citations and numbering, and optionally evaluates token efficiency.

Installation

pip install porosdata-processor

Optional extras:

# Token evaluation support
pip install "porosdata-processor[eval]"

# Streaming JSON parsing for large files
pip install "porosdata-processor[batch]"

Python 3.11+ is supported.

What The Package Does

  • Cleans scientific text while preserving LaTeX formulas via a placeholder-based protect/restore mechanism (Shield).
  • Normalizes whitespace, Unicode, citations, numbering, and repairs OCR errors.
  • Provides a Python API for single-text processing.
  • Provides a CLI for batch processing MinerU *_content_list.json files.
  • Optionally computes token-efficiency statistics when transformers is installed.

Python API

from processor import TextCleaner

cleaner = TextCleaner()
result = cleaner.clean("Recent studies 【1】 show α-phase stability.")
print(result)

Example output:

Recent studies ref[1] show \alpha-phase stability.

Custom pipeline example:

from processor import TextCleaner

cleaner = TextCleaner(
    pipeline=[
        "unicode_normalization",
        "patterns_cleaning",
        "normalize_whitespace",
    ]
)

result = cleaner.clean("Text   with   extra spaces")
print(result)

Optional evaluation mode:

from processor import TextCleaner

cleaner = TextCleaner.with_tokenizer_evaluation("gpt2")
result = cleaner.clean("Recent studies 【1】 show α-phase stability.", eval_mode=True)
print(result["processed_text"])
print(result["evaluation"]["overall"]["compression_rate"])

CLI Batch Processing

The CLI recursively scans the input directory for MinerU *_content_list.json files and writes cleaned JSON outputs plus processing_report.json to the output directory.

porosdata-processor cleaning \
    --input-dir "data/Raw Database" \
    --output-dir "data/Processed Database" \
    --max-workers 4

PowerShell:

porosdata-processor cleaning `
    --input-dir "data/Raw Database" `
    --output-dir "data/Processed Database" `
    --max-workers 4

Enable optional features:

porosdata-processor cleaning \
    --input-dir "data/Raw Database" \
    --output-dir "data/Processed Database" \
    --enable-evaluation \
    --max-workers 4

PowerShell:

porosdata-processor cleaning `
    --input-dir "data/Raw Database" `
    --output-dir "data/Processed Database" `
    --enable-evaluation `
    --max-workers 4

Script Entrypoints

For repository-level operations, use these two scripts:

  • scripts/run_processeddataset.sh: run full cleaning from data/Raw Database to data/Processed Database
  • scripts/run_rulesupplement.sh: run the rule-supplement governance flow and write iteration artifacts to data/Rule Supplement Database/<RUN_ID>

Common flags:

  • --input-dir: input directory containing MinerU outputs
  • --output-dir: output directory for cleaned files
  • --enable-evaluation: enable token-efficiency evaluation
  • --max-workers: set the number of worker processes
  • --force-reprocess: ignore existing outputs and re-run processing
  • --memory-limit: memory limit in MB
  • --log-level: DEBUG, INFO, WARNING, or ERROR
  • --heartbeat-seconds: emit runtime heartbeat logs every N seconds

Scope And Input Format

  • Batch processing is designed for MinerU-generated JSON content lists, not for generic JSONL, Parquet, or HDF5 datasets.
  • The primary public API is TextCleaner for string-based cleaning and the porosdata-processor CLI for directory-based processing.
  • Commands such as audit, evaluation, and rulegovernance are also available from the CLI, and the rulegovernance subcommands are intended for internal data-governance workflows.

License

PorosData-Processor is released under the CC BY 4.0 License.

Metadata

Release files for porosdata-processor 0.4.1

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

Source distribution (sdist)

Source distribution for porosdata-processor 0.4.1
File Size Uploaded Provenance Actions
porosdata_processor-0.4.1.tar.gz 91.1 kB Without provenance Details for porosdata_processor-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for porosdata-processor 0.4.1
File Interpreter ABI Platform Actions
porosdata_processor-0.4.1-py3-none-any.whl Python 3 none any Details for porosdata_processor-0.4.1-py3-none-any.whl

Total release size: 199.3 kB

Release files / porosdata_processor-0.4.1.tar.gz

Download URL porosdata_processor-0.4.1.tar.gz
Size 91.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c0773205a70fbf422fd1ca2d27beb2f69db9024183bd5f1e64d3771b62941d14
BLAKE2b-256 checksum
How to use checksums
de05f477957e9ae9e2c998e704961853ea3da0d81713a5e870bad0ee8d907be4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.6

Release files / porosdata_processor-0.4.1-py3-none-any.whl

Download URL porosdata_processor-0.4.1-py3-none-any.whl
Size 108.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d7145294a827b9777e837c293419a50ed0d23d0330be04bd4d3f8e631bb65086
BLAKE2b-256 checksum
How to use checksums
3a98704e117811402130310d7c15ad446a9f78697d63d488d7672bb85161bf36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.6

Security for porosdata-processor 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.

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