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 eng_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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eng_input_cleaner-0.1.1.tar.gz.
File metadata
- Download URL: eng_input_cleaner-0.1.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7502c6fe1662f8a2ea566b515dd80ee555595b2dd7e684f1d9d20df9aa6d8277
|
|
| MD5 |
af83a7bac2fb5f91d84f5725e801998a
|
|
| BLAKE2b-256 |
beb7740ceaa73b08c3bc8897e0832dc2226974a5e903db8bc790918458434fff
|
File details
Details for the file eng_input_cleaner-0.1.1-py3-none-any.whl.
File metadata
- Download URL: eng_input_cleaner-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72948f8f9b1c389f4df6499686d8e1629b026e7cb8be6ffe7893c52f450e2648
|
|
| MD5 |
0da1861725c122dc1ac6a4c924b32702
|
|
| BLAKE2b-256 |
27e6a2e5c8bcaaf16047229be91e415e47bf766bfd0dfcebba809aaa5d96473d
|