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)
Metadata
Release files for eng-input-cleaner 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| eng_input_cleaner-0.1.2.tar.gz | 13.2 kB | Without provenance | Details for eng_input_cleaner-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| eng_input_cleaner-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for eng_input_cleaner-0.1.2-py3-none-any.whl |
Total release size: 26.2 kB
Release files / eng_input_cleaner-0.1.2.tar.gz
| Download URL | eng_input_cleaner-0.1.2.tar.gz |
|---|---|
| Size | 13.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b15fba80bd2e5af4429d062c183798011093234ec9fcea53c8dfb2670dabc801
|
|
BLAKE2b-256 checksum How to use checksums |
3aa4a55b711793ffc6ee192ce2fa54f0f428956c7418e41ef02f63aace9fb73d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / eng_input_cleaner-0.1.2-py3-none-any.whl
| Download URL | eng_input_cleaner-0.1.2-py3-none-any.whl |
|---|---|
| Size | 13.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fd3fc9d824d5532acc807ea7d212efce80283da2fbb76eaf05fd9478c414826c
|
|
BLAKE2b-256 checksum How to use checksums |
ad3cd1d7561f76f13e54acce17929067cd1afd91484011ff347845b8f98e3a7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Security for eng-input-cleaner 0.1.2
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.