typo
typo is a python package to simulate typographical errors in English language.
Release 0.1.7
- Ability to preserve first and/or last characters in error methods.
Usage
import typo
import datetime
myStrErrer = typo.StrErrer('Hello World! Happy new year 2021.', seed=31)
print(myStrErrer.missing_char().result)
# Should print 'ello World! Happy new year 2021.'
myStrErrer = typo.StrErrer('Hello World! Happy new year 2021.', seed=31)
print(myStrErrer.missing_char(preservefirst=True).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 method | Description | Sample output |
|---|---|---|
| char_swap(preservefirst=False, preservelast=False) | Swaps two random consecutive word characters in the string. | Hello World! Ahppy new year 2021. |
| missing_char(preservefirst=False, preservelast=False) | Skips a random word character in the string. | Hllo World! Happy new year 2021. |
| extra_char(preservefirst=False, preservelast=False) | Adds an extra, keyboard-neighbor, letter next to a random word character. | Hrello World! Happy new year 2021. |
| nearby_char(preservefirst=False, preservelast=False) | 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:
| Error method | Description | Input | Sample output |
|---|---|---|---|
| digit_swap(preservefirst=False, preservelast=False) | Swaps two random consecutive digits in the integer. | 1234567890 | 1324567890 |
| missing_digit(preservefirst=False, preservelast=False) | Skips a random digit in the integer. | -1234567890 | -123457890 |
| extra_digit(preservefirst=False, preservelast=False) | Adds an extra, keyboard-neighbor, digit next to a random digit in the integer. | 1234567890 | 12345678920 |
| nearby_digit(preservefirst=False, preservelast=False) | 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:
| Error method | Description | Input | Sample 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 |
Metadata
Release files for typo 0.1.7
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 |
|---|---|---|---|---|
| typo-0.1.7.tar.gz | 7.3 kB | Without provenance | Details for typo-0.1.7.tar.gz |
Release files / typo-0.1.7.tar.gz
| Download URL | typo-0.1.7.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
36cd716d3a75a58b16e587ffb1135c1790d152db15f7247be23a29358fb62a02
|
|
BLAKE2b-256 checksum How to use checksums |
3d7226a99adf855f65d4f25b110e033a5e25dcb98842e383c7b7b7020df1dd13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.8.6
|
Security for typo 0.1.7
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.