Skip to main content

Auto-removes headers, footers, and noise from PDF text for RAG apps.

Project description

Here is a professional, copy-paste ready README.md for your rag-scrubber library.

This file is crucial because it is the "front page" of your project on GitHub and PyPI. A good README explains what the problem is and how your library solves it instantly.


rag-scrubber

Clean your "dirty" PDF text before feeding it to LLMs.

rag-scrubber is a lightweight Python library designed for RAG (Retrieval-Augmented Generation) pipelines. It automatically detects and removes recurring headers, footers, and page numbers from extracted text, and fixes broken hyphenation.

😟 The Problem

When extracting text from PDFs (especially corporate reports or scanned docs), you often get artifacts that confuse LLMs:

"The Q3 revenue was CONFIDENTIAL REPORT 2024 higher than expected..."

These interruptions waste tokens and degrade model performance. rag-scrubber cleans this mess up.

✨ Features

  • Auto-Header/Footer Removal: Uses positional statistics to detect lines that repeat across pages (e.g., "Page 1 of 50", "Confidential").
  • Smart De-Hyphenation: Fixes words split across lines (e.g., com- + puter computer) without merging proper nouns.
  • Zero-Shot Configuration: Works out of the box with sensible defaults, or tune the sensitivity yourself.
  • Lightweight: No heavy ML dependencies. pure Python logic.

📦 Installation

pip install rag-scrubber

🚀 Quick Start

from rag_scrubber import RAGScrubber

# 1. Simulate dirty text (usually coming from PyPDF2 or PDFMiner)
pages = [
    "Q3 FINANCIAL REPORT - CONFIDENTIAL\nThe revenue increased by 20%.\nPage 1",
    "Q3 FINANCIAL REPORT - CONFIDENTIAL\nOperating costs were lowered.\nPage 2",
    "Q3 FINANCIAL REPORT - CONFIDENTIAL\nNew user acquisition is sta-\nble.\nPage 3"
]

# 2. Initialize the scrubber
# threshold=0.4 means if a line appears in >40% of pages, it's garbage.
scrubber = RAGScrubber(threshold=0.4)

# 3. Clean the text
clean_text = scrubber.clean(pages)

print(clean_text)

Output:

The revenue increased by 20%.

Operating costs were lowered.

New user acquisition is stable.

⚙️ Advanced Usage

You can adjust the sensitivity if it is deleting too much (or too little).

# Low threshold (0.1) = Very aggressive (removes anything that repeats even slightly)
# High threshold (0.9) = Very safe (only removes exact matches on almost every page)
scrubber = RAGScrubber(threshold=0.2) 

🤝 Contributing

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature/new-logic).
  3. Commit your changes.
  4. Push to the branch.
  5. Open a Pull Request.

📄 License

MIT License. Free to use for commercial and personal projects.


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

rag_scrubber-0.1.2.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

rag_scrubber-0.1.2-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file rag_scrubber-0.1.2.tar.gz.

File metadata

  • Download URL: rag_scrubber-0.1.2.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for rag_scrubber-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4398b4d970b2f3fe2ac9de184e42a6f57be4027849a3e9ec10f4a4f0403e6127
MD5 4b4a9ee5b3cdc9531ceba4584d9595d5
BLAKE2b-256 d609070fdfb4723bb4ec50eb6600fd38bd25985b82ba01784973d0540cd3846d

See more details on using hashes here.

File details

Details for the file rag_scrubber-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: rag_scrubber-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for rag_scrubber-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c1ba45214006b130e0b970f9d7f9b227cb89a572a255c652ca0bb54d85e8531b
MD5 9f6dbaa8027573fa25358bee2d282742
BLAKE2b-256 f4085140ae57c82c372698a843e84898b25bbddc79dd2529a0222321655b0d2b

See more details on using hashes here.

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