Skip to main content

Text cleaning, scoring and compression pipeline

Reason this release was yanked:

fix

Project description

Eng Input Cleaner

Lightweight text preprocessing pipeline for cleaning, scoring and compressing user input.

Designed for LLM optimization, noise reduction and token efficiency.


Features

  • Text normalization and cleanup
  • Noise detection using heuristic scoring
  • Input compression (removes low-value words)
  • Quality scoring system (0–100)
  • Smart truncation for long inputs
  • Token reduction tracking using tiktoken

Installation

pip install eng_input_cleaner

Or local development:

pip install -e .

Quick Start

from input_cleaner import process

result = process("hello hello I really really need help with this")

print(result)

Example Output

{
  "original": "hello hello I really really need help with this",
  "cleaned": "i really need help with this",
  "output": "need help",
  "score": 78,
  "status": "accepted",
  "was_compressed": true,
  "tokens_before": 10,
  "tokens_after": 2,
  "token_reduction": 0.8,
  "token_reduction_pct": "80.00%"
}

Pipeline Overview

The system processes text in 4 sequential stages:

raw input
    ↓
1. Cleaner     ← normalizes and removes noise
    ↓
2. Scorer      ← evaluates quality on cleaned text (0–100)
    ↓
3. Decision    ← accepts or blocks based on score
    ↓
4. Compressor  ← always runs on accepted text
    ↓
  LLM

1. Cleaning

  • Normalize text (lowercase, symbols, encoding)
  • Remove duplicate words and repeated characters
  • Filter noise patterns using heuristic scoring
  • Collapse redundant symbols

2. Scoring

Evaluates the cleaned text using:

  • Character entropy
  • Character diversity
  • Vowel ratio
  • Common bigram ratio
  • Consonant run length
  • Cyclic and structural pattern detection

3. Decision

  • Block low-quality or noisy input
  • Accept valid input (short or long)
  • Apply smart truncation for very long inputs

4. Compression

Runs on every accepted text regardless of score:

  • Removes low-value words (articles, weak intensifiers, filler)
  • Preserves intent words, negations, question words and structured data

Status Values

Status Meaning
accepted Valid input, normal or long length
accepted_short Valid input, short (1–5 words)
blocked_empty Empty or whitespace-only input
blocked_low_score Quality score below threshold
blocked_noise Single long token detected as noise
blocked_low_info Too short to carry meaningful information

Output Fields

Field Type Description
original str Raw input as received
cleaned str After normalization and noise removal
output str | None Final text sent to LLM, None if blocked
score float Quality score from 0 to 100
status str Pipeline decision result
was_compressed bool Whether compression was applied
tokens_before int Token count of original input
tokens_after int Token count of final output
token_reduction float Fractional reduction (e.g. 0.8)
token_reduction_pct str Human-readable reduction (e.g. "80.00%")

Use Cases

  • Preprocessing user input for LLMs
  • Reducing token costs
  • Filtering spam or noisy text
  • Improving prompt quality
  • Input validation layer for APIs

Requirements

  • Python 3.8+
  • tiktoken

Project Structure

input_cleaner/
├── cleaner.py      ← normalization and noise filtering
├── scorer.py       ← quality scoring (0–100)
├── decision.py     ← accept / block logic
├── compressor.py   ← low-value word removal
└── pipeline.py     ← orchestrates all stages

Design Goals

  • Fast — pure Python, no heavy dependencies
  • Deterministic — no randomness, same input always produces same output
  • Modular — each stage is isolated and independently testable
  • Easy to extend — thresholds and word lists are configurable

License

Apache-2.0


Author

marlon (MARLM8)

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

eng_input_cleaner-0.1.0.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

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

eng_input_cleaner-0.1.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: eng_input_cleaner-0.1.0.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for eng_input_cleaner-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2a31c4c819a7f9a66556e9d662189d233fed19c7d7026b940ca0a5975dfcdfc4
MD5 ff223cd7968d9594acb30c3ca2fe1c7d
BLAKE2b-256 975d91754240e0cb5cf5b3ad1b1160dff07801b23e9adb3094df2764aaa26b45

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for eng_input_cleaner-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4af0612a22135e6faa921bb2fb254f542972cf936f0f6651c536ca0a0e1424a8
MD5 310ede85a102bfafcb3de5ab33ddef13
BLAKE2b-256 4d12cc3094e5354b99ed7d4b7c436ec9048e19e447d80efc214d440511108c85

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