Skip to main content

A python package to simulate typographical errors.

Project description

typo

typo is a python package to simulate typographical errors in English language.

Usage

import typo
import datetime

myStrErrer = typo.StrErrer('Hello World! Happy new year 2021.', seed=2)
print(myStrErrer.missing_char().result)
# Should print 'Hllo World! Happy new year 2021.'

myStrErrer = typo.StrErrer('Hello World! Happy new year 2021.', seed=2)
print(myStrErrer.missing_char().char_swap().result)
# Should print 'Hlol World! Happy new year 2021.'

myIntErrer = typo.IntErrer(34343, seed=1)
print(myIntErrer.similar_digit().result)
# Should print 39343

myDateErrer = typo.DateErrer(datetime.datetime.strptime("8 Mar 95", "%d %b %y"))
print(myDateErrer.date_month_swap().result)
# Should print 1995-08-03 00:00:00

Currently, following types of typos can be simulated:

String typos:

Given the input Hello World! Happy new year 2021., different error types produce the following errors.

Error type Description Output
char_swap Swaps two random consecutive word characters in the string. Hello World! Ahppy new year 2021.
missing_char Skips a random word character in the string. Hllo World! Happy new year 2021.
extra_char Adds an extra, keyboard-neighbor, letter next to a random word character. Hrello World! Happy new year 2021.
nearby_char Replaces a random word character with keyboard-neighbor letter. Hello World! Happy new ysar 2021.
similar_char Replaces a random word character with another visually similar character. Hell0 world! Happy new year 2021.
skipped_space Skips a random space from the string. Hello world! Happy new year2021.
random_space Adds a random space in the string. Hell o world! Happy new year 2021.
repeated_char Repeats a random word character. Hello worrld! Happy new year 2021.
unichar Replaces a random consecutive repeated letter with a single letter. Hello world! Hapy new year 2021.

Integer typos:

Method Description Input Output
digit_swap Swaps two random consecutive digits in the integer. 1234567890 1324567890
missing_digit Skips a random digit in the integer. -1234567890 -123457890
extra_digit Adds an extra, keyboard-neighbor, digit next to a random digit in the integer. 1234567890 12345678920
nearby_digit Replaces a random digit in the integer with a keyboard-neighbor digit. 1234567890 1234567892
similar_digit Replaces a random digit with another visually similar digit. 1234567890 1234567896
repeated_digit Repeats a random digit in the integer. 1234567890 12345678900
unidigit Replaces a random consecutive repeated digit with a single digit. -112233445566 -11233445566

Datetime typos:

Method Description Input Output
date_month_swap Swaps the day and month of the date if the value of the day is less than or equal to 12. 8 Mar 95 3 Aug 95

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

typo-0.1.4.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

typo-0.1.4-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file typo-0.1.4.tar.gz.

File metadata

  • Download URL: typo-0.1.4.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.7.3

File hashes

Hashes for typo-0.1.4.tar.gz
Algorithm Hash digest
SHA256 8e63b64a80bbc3ca80ef0215ffc25be2d80086486de699b19dc0564bb12bbe19
MD5 8b1c69e816e0b19e5806d222381372d9
BLAKE2b-256 8085ed9009594e1744b5dafd6ebeac914100e825794d0b52f49f411acdfb5c23

See more details on using hashes here.

File details

Details for the file typo-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: typo-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.7.3

File hashes

Hashes for typo-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fcdcc67ee20675fb49af2163915e4585b2f4567972c8996b4ff1d621f400f218
MD5 67223f8692c08574b79f244ff237d1ab
BLAKE2b-256 5fe154a30a61a4e5b8c22cef7160c0cd2d29fa0f58e1f247b0029600fc4e195e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page