wordvariations


Namewordvariations JSON
Version 0.10 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/wordvariations
SummaryGenerates possible typing errors from a given string (neighboring keys and switch letters)
upload_time2023-08-01 02:21:41
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords string typing errors
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Generates possible typing errors from a given string (neighboring keys and switch letters) 

## pip install wordvariations 

#### Tested against Windows 10 / Python 3.10 / Anaconda 



## switch_letters: 

This function generates variations by switching neighboring letters in the input text as they might occur due to typographical errors. 
It takes into account the spatial relationships between keys on the specified keyboard layout and creates multiple 
unique variations by switching pairs of neighboring letters.

## change_letters

This function generates variations by changing some of the letters in the input text to neighboring keys on the specified keyboard layout. 
The resulting variations mimic possible errors caused by mistyping or keyboard layout peculiarities. 
Users can control the maximum number of letter changes using the max_change parameter.

These functions are useful for various applications, such as generating typing exercises for language learners, 
creating diverse test datasets for natural language processing applications, or analyzing keyboard layouts' 
ergonomic design. The module's advantages include efficiency through LRU caching, 
customizability with adjustable parameters, and the ability to preserve the order of appearance for unique variations.

Users interested in exploring potential typing errors, keyboard layouts, and text processing applications can 
benefit from this module as it provides an easy-to-use interface for generating diverse text variations based on keyboard layout relationships."



### How to use switch_letters

```python
Generate variations of the input text by switching neighboring letters on the specified keyboard layout.

Parameters:
-----------
text : str
	The input text for which to generate variations.
keyboard_layout : str
	The identifier of the keyboard layout. Should be one of the supported layouts (call show_all_keyboards() to see them).
max_switches : int, optional
	The maximum number of switches to perform. Default is 2.
switch_numbers : bool, optional
	If True, allows switching numbers as well. Default is False.
timeout : int or float, optional
	The maximum time (in seconds) to spend generating variations. Default is 0.3 seconds.

Returns:
--------
list
	A list containing the original text (index 0) and the variations obtained by switching neighboring letters.
	The variations may include up to `max_switches` switches, and the result is unique, preserving the order.

Example:
--------
from wordvariations import switch_letters, change_letters, show_all_keyboards
text = "Gustavo Lima"
keyboard_layout = "kbdbr_1"
print(
	switch_letters(
		text=text,
		keyboard_layout=keyboard_layout,
		max_switches=10,
		switch_numbers=False,
		timeout=0.3,
	)
)
['Gustavo Lima', 'Gutsavo Lima', 'Gutsavo Lmia', 'Gutsaov Lmia']

Note:
-----
The function uses an LRU cache to speed up repeated calls with the same inputs.
```


### How to use change_letters

```python
Generate variations of the input text by changing some of the letters to their neighboring keys on the specified keyboard layout.

Parameters:
-----------
text : str
	The input text for which to generate variations.
keyboard_layout : str
	The identifier of the keyboard layout. Should be one of the supported layouts (call show_all_keyboards() to see them).
max_change : int, optional
	The maximum number of letters to change. Default is 1.
include_numbers : bool, optional
	If True, includes numbers in the allowed letters. Default is False.

Returns:
--------
str
	A variation of the input text with some letters changed to neighboring keys.

Example:
--------
from wordvariations import switch_letters, change_letters, show_all_keyboards
text = "Gustavo Lima"
keyboard_layout = "kbdbr_1"
for q in range(3):
	print(change_letters(text, keyboard_layout, max_change=1, include_numbers=False))
# Gustavo Limq
# Gjstavo Lima
# Vustavo Lima

Note:
-----
The function uses an LRU cache to speed up repeated calls with the same inputs.
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/wordvariations",
    "name": "wordvariations",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "string,typing,errors",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/25/2b/1f7c920d1ec5c2c8cc22fb35327eb56218e53586972053a85a4fd62860d3/wordvariations-0.10.tar.gz",
    "platform": null,
    "description": "\r\n# Generates possible typing errors from a given string (neighboring keys and switch letters) \r\n\r\n## pip install wordvariations \r\n\r\n#### Tested against Windows 10 / Python 3.10 / Anaconda \r\n\r\n\r\n\r\n## switch_letters: \r\n\r\nThis function generates variations by switching neighboring letters in the input text as they might occur due to typographical errors. \r\nIt takes into account the spatial relationships between keys on the specified keyboard layout and creates multiple \r\nunique variations by switching pairs of neighboring letters.\r\n\r\n## change_letters\r\n\r\nThis function generates variations by changing some of the letters in the input text to neighboring keys on the specified keyboard layout. \r\nThe resulting variations mimic possible errors caused by mistyping or keyboard layout peculiarities. \r\nUsers can control the maximum number of letter changes using the max_change parameter.\r\n\r\nThese functions are useful for various applications, such as generating typing exercises for language learners, \r\ncreating diverse test datasets for natural language processing applications, or analyzing keyboard layouts' \r\nergonomic design. The module's advantages include efficiency through LRU caching, \r\ncustomizability with adjustable parameters, and the ability to preserve the order of appearance for unique variations.\r\n\r\nUsers interested in exploring potential typing errors, keyboard layouts, and text processing applications can \r\nbenefit from this module as it provides an easy-to-use interface for generating diverse text variations based on keyboard layout relationships.\"\r\n\r\n\r\n\r\n### How to use switch_letters\r\n\r\n```python\r\nGenerate variations of the input text by switching neighboring letters on the specified keyboard layout.\r\n\r\nParameters:\r\n-----------\r\ntext : str\r\n\tThe input text for which to generate variations.\r\nkeyboard_layout : str\r\n\tThe identifier of the keyboard layout. Should be one of the supported layouts (call show_all_keyboards() to see them).\r\nmax_switches : int, optional\r\n\tThe maximum number of switches to perform. Default is 2.\r\nswitch_numbers : bool, optional\r\n\tIf True, allows switching numbers as well. Default is False.\r\ntimeout : int or float, optional\r\n\tThe maximum time (in seconds) to spend generating variations. Default is 0.3 seconds.\r\n\r\nReturns:\r\n--------\r\nlist\r\n\tA list containing the original text (index 0) and the variations obtained by switching neighboring letters.\r\n\tThe variations may include up to `max_switches` switches, and the result is unique, preserving the order.\r\n\r\nExample:\r\n--------\r\nfrom wordvariations import switch_letters, change_letters, show_all_keyboards\r\ntext = \"Gustavo Lima\"\r\nkeyboard_layout = \"kbdbr_1\"\r\nprint(\r\n\tswitch_letters(\r\n\t\ttext=text,\r\n\t\tkeyboard_layout=keyboard_layout,\r\n\t\tmax_switches=10,\r\n\t\tswitch_numbers=False,\r\n\t\ttimeout=0.3,\r\n\t)\r\n)\r\n['Gustavo Lima', 'Gutsavo Lima', 'Gutsavo Lmia', 'Gutsaov Lmia']\r\n\r\nNote:\r\n-----\r\nThe function uses an LRU cache to speed up repeated calls with the same inputs.\r\n```\r\n\r\n\r\n### How to use change_letters\r\n\r\n```python\r\nGenerate variations of the input text by changing some of the letters to their neighboring keys on the specified keyboard layout.\r\n\r\nParameters:\r\n-----------\r\ntext : str\r\n\tThe input text for which to generate variations.\r\nkeyboard_layout : str\r\n\tThe identifier of the keyboard layout. Should be one of the supported layouts (call show_all_keyboards() to see them).\r\nmax_change : int, optional\r\n\tThe maximum number of letters to change. Default is 1.\r\ninclude_numbers : bool, optional\r\n\tIf True, includes numbers in the allowed letters. Default is False.\r\n\r\nReturns:\r\n--------\r\nstr\r\n\tA variation of the input text with some letters changed to neighboring keys.\r\n\r\nExample:\r\n--------\r\nfrom wordvariations import switch_letters, change_letters, show_all_keyboards\r\ntext = \"Gustavo Lima\"\r\nkeyboard_layout = \"kbdbr_1\"\r\nfor q in range(3):\r\n\tprint(change_letters(text, keyboard_layout, max_change=1, include_numbers=False))\r\n# Gustavo Limq\r\n# Gjstavo Lima\r\n# Vustavo Lima\r\n\r\nNote:\r\n-----\r\nThe function uses an LRU cache to speed up repeated calls with the same inputs.\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Generates possible typing errors from a given string (neighboring keys and switch letters)",
    "version": "0.10",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/wordvariations"
    },
    "split_keywords": [
        "string",
        "typing",
        "errors"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bcdd4915bdc916c3b4155e60c049dfe7de476c0752c744227537e3a24d4fedc8",
                "md5": "4061e506a33fa0de7639010519a4bd71",
                "sha256": "a9087cf2ec1a62a32a3c409aa44b2e2bb01679221e236ce2e0c2f69d64311d66"
            },
            "downloads": -1,
            "filename": "wordvariations-0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4061e506a33fa0de7639010519a4bd71",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 8897,
            "upload_time": "2023-08-01T02:21:39",
            "upload_time_iso_8601": "2023-08-01T02:21:39.476603Z",
            "url": "https://files.pythonhosted.org/packages/bc/dd/4915bdc916c3b4155e60c049dfe7de476c0752c744227537e3a24d4fedc8/wordvariations-0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "252b1f7c920d1ec5c2c8cc22fb35327eb56218e53586972053a85a4fd62860d3",
                "md5": "f9fb6013c56c136163d0fc82e403bfc1",
                "sha256": "8aff9e9593ac24810776999d81a1c5653fa9af5db492b4b3b6e709c28629f244"
            },
            "downloads": -1,
            "filename": "wordvariations-0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "f9fb6013c56c136163d0fc82e403bfc1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6938,
            "upload_time": "2023-08-01T02:21:41",
            "upload_time_iso_8601": "2023-08-01T02:21:41.212348Z",
            "url": "https://files.pythonhosted.org/packages/25/2b/1f7c920d1ec5c2c8cc22fb35327eb56218e53586972053a85a4fd62860d3/wordvariations-0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-01 02:21:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "wordvariations",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "wordvariations"
}
        
Elapsed time: 0.09658s