Skip to main content

A lightweight Python library to clean raw text and documents before NLP and LLM workflows.

Project description

DocScrub

Python pytest Ruff ftfy

DocScrub is a lightweight Python library for cleaning raw text before NLP, LLM, and RAG workflows.

Features

  • Unicode fixing
  • URL removal
  • Email removal
  • Page number removal
  • Duplicate line removal
  • Whitespace cleanup

Installation

pip install docscrub

Quick Start

from docscrub import Cleaner

cleaner = Cleaner()

raw_text = "Français https://example.com user@example.com\n\nHello\nHello"
clean_text = cleaner.clean(raw_text)

print(clean_text)

Examples

Input:

Visit https://example.com for details

Output:

Visit for details

Input:

Hello
Hello
World

Output:

Hello
World

Supported Cleaners

Unicode Cleaner

Fixes broken text encoding and normalizes Unicode characters. DocScrub uses ftfy for this step.

URL Cleaner

Removes common URLs such as https://example.com.

Email Cleaner

Removes email addresses such as user@example.com.

Page Number Cleaner

Removes page-number-only lines such as Page 1 of 10, Page 5, or 12.

Duplicate Line Cleaner

Removes repeated lines while keeping the first copy.

Whitespace Cleaner

Removes extra spaces, tabs, blank lines, and line padding.

Project Structure

  • docscrub/ contains the library code.
  • docscrub/cleaners/ contains one simple function per cleaning step.
  • docscrub/patterns/ stores regular expression patterns shared by cleaners.
  • docscrub/utils/ is available for small helper functions.
  • tests/ contains beginner-friendly pytest tests.
  • examples/ contains short example scripts.

Development Setup

Install the project dependencies with uv, then run the test and lint commands:

uv sync
uv run pytest
uv run ruff check .
uv run ruff format .

Contributing

Beginner-friendly contributions are welcome.

  1. Clone the repository.
  2. Install the dependencies with uv sync.
  3. Run uv run pytest before and after your change.
  4. Keep the code simple and easy to read.
  5. Open a pull request with a short description of what changed.

License

DocScrub is released under the MIT License. See the LICENSE file for details.

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

docscrub-0.1.0.tar.gz (102.3 kB view details)

Uploaded Source

Built Distribution

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

docscrub-0.1.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file docscrub-0.1.0.tar.gz.

File metadata

  • Download URL: docscrub-0.1.0.tar.gz
  • Upload date:
  • Size: 102.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.0

File hashes

Hashes for docscrub-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fb4c88dabe37e485689230934fa7b15e832a496a300a23c04b7063e5f174c74b
MD5 b6941965ec1295d414ce3f06400e7e6e
BLAKE2b-256 de42279b3413c2a45f294a7ed1c6e111f3857cb0d4d5400993a3d53f25f7e15f

See more details on using hashes here.

File details

Details for the file docscrub-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: docscrub-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.0

File hashes

Hashes for docscrub-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 959d86c9ea02db84847f0a53a3471f31c5bca74278b6b17840fcd97fcb1108f1
MD5 e78fbf32cf2e7b639753494541da8fd8
BLAKE2b-256 8ba1db5a23516b3ac6aca380e303f5c229d2c44a6b205a6a1e1a04a593e852c4

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