Skip to content

Improve error correction and modernize packaging#2

Open
KrAsH-CoD3 wants to merge 6 commits intoLax3n:masterfrom
KrAsH-CoD3:fix/proofreading-logic-and-standardization
Open

Improve error correction and modernize packaging#2
KrAsH-CoD3 wants to merge 6 commits intoLax3n:masterfrom
KrAsH-CoD3:fix/proofreading-logic-and-standardization

Conversation

@KrAsH-CoD3
Copy link

Overview

Major refactor of the typing simulation engine with improved error detection, modern Python packaging, and enhanced code quality.

What's New

Smarter Error Correction

Word Boundary Checking

Automatically catches errors when typing spaces or punctuation marks.

# Before: "Thsi is a wrnog snetence" (errors pile up)
# After:  "This is a wrong sentence" (caught at spaces)

Impact: Prevents multiple errors from accumulating across words.

Backspace Locking

Once error correction starts, it completes before resuming typing.

Impact: No more inefficient back-and-forth between typing and deleting.

I also realize sometime at the end of the typing_text value, it continuously type and backspace making it an endless loop.

Originally posted by @KrAsH-CoD3 in #1

Drift Detection

Progressive error detection based on distance from the mistake.

Impact: Realistic behavior - you notice when something "feels wrong" after a few characters.

Unified Monitoring

Replaced two-mode system (typing/review) with continuous error detection.

Impact: Cleaner code, better state management, errors caught throughout.

🔧 Code Quality Improvements

Example

Before

typer = MarkovTyper("This is a test")
typer.run()
# Output: "Thsi is a testt"  ← errors accumulate

After

typer = MarkovTyper("This is a test")
typer.run()
# Output: "This is a test"  ← caught at word boundaries

Technical Details

Error Detection Hierarchy

The system checks for errors in this order:

  1. Backspace Lock - Continue correcting if already fixing
  2. End of Text - Correct if done typing but text doesn't match
  3. Word Boundaries ⭐ NEW - Check at spaces/punctuation
  4. Drift Detection ⭐ NEW - Notice based on distance from error
  5. Immediate Catch - Random chance to notice right away

Architecture

Old: Normal Typing Mode → Review Mode (at end)
New: Continuous Monitoring → Type or Correct (every step)

Files Changed

  • typer.py - Core algorithm refactor
  • pyproject.toml - New packaging config (added)
  • setup.py - Removed (deprecated)
  • simulation.py - Fixed terminal output

Replace two-mode system with unified monitoring that catches errors at word boundaries, prevents backspace loops, and uses drift detection for more realistic human typing behavior.
- Replaced full-block screen refreshes with character-by-character updates
- Implemented real backspace simulation using '\b \b'
- Added multi-line cursor management for backspacing across line breaks
- Greatly improved visual fidelity by eliminating terminal flicker
@KrAsH-CoD3 KrAsH-CoD3 changed the title Improve typing simulation with hierarchical error detection and word-boundary validation Improve error correction and modernize packaging Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Uncorrected mistakes

1 participant