autoINcorrect 🤖💥
"A spell-checker-in-reverse"
Ever stared at your phone, absolutely convinced you typed "meeting," only for it to send "meating"? We've all been victims of autocorrect. But it got me thinking: what if we turned the tables?
This is the autoINcorrect system. It's a "spell-checker-in-reverse" that, instead of fixing mistakes, artfully creates them.
The Idea
This isn't just random chaos. It's a sophisticated system built on a simple, but (if I do say so myself) pretty smart idea: what if, to test how good a "fixer" is, we first built the perfect "breaker"?
By simulating how humans make real, plausible errors, we can build the ultimate stress-test for any real autocorrect model out there. It's an entire NLP pipeline, built in reverse.
This system understands:
Physical Errors: Simulating "fat-finger" slips from an actual keyboard layout.
Cognitive Errors: Simulating "brain-fart" moments like homophone swaps (your vs. you're).
Semantic Errors: Simulating "near-miss" malapropisms like banking -> banker using NLP (NLTK) and word embeddings (GloVe).
Formatting Errors: Simulating real-world punctuation mistakes and random case-flipping.
📦 First-Time Setup
Before you run the script, you'll need the necessary NLP models. Your pipeline.py file includes a helper function to do this automatically.
The first time you import or run the package, it will:
Check for the necessary nltk data (WordNet, Punkt, Tagger).
Download any missing nltk packages.
The first time you use the "Malapropism" module, it will download the glove-wiki-gigaword-100 model (this may take a minute).
🚀 Quick Start & Usage
This package is designed to be simple to use and easy to chain. The main wrapper function is auto_incorrect().
--- Import the main functions ---
from autoINcorrect import auto_incorrect, word_error, corrupt_format
my_text = "I am running a test on my banking application for its creative standards. It's a beautiful day to see if your function works correctly."
--- Option 1: Run the full chain with one function ---
(This uses all default settings)
print("--- Full Corruption (Default) ---")
This is the main wrapper function you'll usually use
corrupted_text = auto_incorrect(my_text) print(corrupted_text)
--- Option 2: Manually chain functions for more control ---
print("\n--- Manual Chaining (Custom Settings) ---")
1. Apply word-based errors
(Let's make errors common, with 70% typos and 30% smart errors)
custom_distribution = { 'fat_finger': 0.7, 'brain_fart': 0.3, 'malapropism': 0.0 } text_with_word_errors = word_error( my_text, error_rate=0.3, # Corrupt 30% of words distribution=custom_distribution )
2. Apply punctuation and case errors to that result
(Let's be aggressive: remove all punctuation and flip 80% of caps)
final_corrupted_text = corrupt_format( text_with_word_errors, add_rate=0.0, replace_rate=0.0, remove_rate=1.0, # 100% chance to remove punctuation case_corruption_prob=0.8 # 80% chance to flip a CAPITAL )
print(f"\nOriginal:\n{my_text}\n") print(f"Corrupted:\n{final_corrupted_text}")
🛠️ Key Modules
Your package is split into two main corruption functions, which are combined in the auto_incorrect() wrapper.
- word_error()
This function handles all word-based corruption. It contains three sub-modules:
⌨️ "Fat Finger" Module: Simulates physical keyboard mistakes.
adjacent_swap: standard -> stamdard (m near n)
transpose: standard -> standrad
delete_char: standard -> standad
insert_char: standard -> standfard
🧠 "Brain Fart" Module: Simulates cognitive "word choice" mistakes.
replace_homophone: your -> you're
replace_morphological: decision -> decide (uses NLTK/WordNet)
🎭 "Malapropism" Module: The smartest module. Creates "near-miss" semantic errors.
replace_semantic_neighbor: banking -> banker (uses GloVe embeddings to find related words with the same root).
- corrupt_format()
This function handles all punctuation and case-based corruption.
Punctuation: Randomly adds (word,), removes (word. -> word), or replaces (word? -> word;) punctuation marks.
Case: Randomly flips CAPITAL letters to lowercase based on a probability.
📦 Installation
pip install autoINcorrect
📜 License
This project is licensed under the MIT License.
Metadata
Release files for autoINcorrect 0.0.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 | |
|---|---|---|---|---|
| autoincorrect-0.0.2.tar.gz | 8.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| autoincorrect-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.1 kB
Release files / autoincorrect-0.0.2.tar.gz
| Download URL | autoincorrect-0.0.2.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
97a957a7c8e8b13f4d81da61858244ff7e647a4ab18f158447dc78d5721b5cfc
|
|
BLAKE2b-256 checksum How to use checksums |
72ba16181f95ee5bacdf616ac6e5cd00163ae6c5ca51eeb349bfc5ab3764a79c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / autoincorrect-0.0.2-py3-none-any.whl
| Download URL | autoincorrect-0.0.2-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8294979fdfeaf01372d3c95152ec132751c398137432ef01dcb8adc05d1f1f9f
|
|
BLAKE2b-256 checksum How to use checksums |
0db99d84fbb6acaffa0311e6b78e9b8d44ffcb02ac9966ef9ae3767b354768a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for autoINcorrect 0.0.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.