python-spell-checker


Namepython-spell-checker JSON
Version 1.1.0 PyPI version JSON
download
home_page
SummaryPython spell checker library; supports English, German, Italian, Spanish, French, and even Code!
upload_time2023-12-01 21:05:01
maintainer
docs_urlNone
author
requires_python>=3.9
licenseCopyright (c) 2021 Harvard90873 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords spell-check spellchecker typos
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python Spell Checker

The **spell checker** is a python package that can check your spelling. It supports **_6_** languages!

It contains the following languages:

- English
- German
- Spanish
- French
- Italian
- Code

**_Code_** is a special language that contains the english language along with syntaxes and keywords of programming languages. This is to prevent the spell checker from marking them as misspelt words when the checker is used on a codebase. The words are stored in `code.txt` in `languages` folder.

All valid words of a language are stored in a text file in the `languages` folder. The words are sorted alphabetically and are in lowercase. You can add your own words to it. You can also delete words from the text file to exclude them as valid words.

# Installation

The easiest way to install the package is to use `pip` or `pip3`:

```bash
pip install python-spell-checker
```

or you can clone the repository and use the files:

```bash
    git clone https://github.com/dev0cloo/python-spell-checker.git
    cd python-spell-checker
```

# Usage

The main file is `checker.py` in the `python_spell` folder.

The `SpellChecker` class is used to check the spelling of a text. It takes two arguments:

- `text`: The text to be checked
- `language`: The language of the text. It is set to `english` by default. The language must be one of the following:
  - `english`
  - `german`
  - `spanish`
  - `french`
  - `italian`
  - `code`

The `check()` method is used to check the spelling of the text. It returns a dictionary object with the following relevant keys:

- `total_words`: The total number of words in the text
- `misspelled_num`: The number of misspelled words in the text
- `words_in_dictionary`: The number of words in the dictionary of the language
- `misspelled_words`: A list of misspelled words

The `has_typos` attribute returns a boolean for if the text has typos or not.

The `number_of_typos()` method returns the number of typos in the text. It takes an optional argument `duplicates` which is set to `False` by default. If it is set to `True`, then each duplicate word is counted as a typo. If it is set to `False`, then each duplicate word is counted as a single typo.

The `get_typos()` method returns a list of misspelt words. It takes the optional arguments `duplicates` and `exclude`. `duplicates` is set to `False` by default and works the same as in `number_of_typos()`. `exclude` is a string or a list of strings that are excluded from the returned list of misspelt words. It is set to `None` by default.

`exclude` can be used to exclude words that are not in the dictionary but are valid words without changing the language file. It takes an optional argument `temp` which is set to `False` by default. If it is set to `True`, then the words are excluded only for the current method call and not the whole instance. If it is set to `False`, then the words are excluded for the whole instance. This is useful if you want to exclude words for a single method call but not for the whole instance.

#### Note

The SpellChecker class calls the `check()` method when it is initialized. So, you can directly use the `has_typos`, `number_of_typos()`, `get_typos()` and `exclude` methods without first calling the `check()` method. You can access the dictionary object returned by the `check()` method using the `checked` attribute.

### Example:

```Python
from python_spell.checker import SpellChecker
text = "The... ! quick browmn fox jumps-over the lazi dog"
checker = SpellChecker(text, "english")

# This returns a dictionary object with all information
check_text = checker.checked
print(check_text)

# This returns a boolean for if the text has typos or not
is_valid = checker.has_typos
print("Does the text have typos? " , is_valid)

# This returns the number of typos (duplicate words are )
num_typos = checker.number_of_typos()
print("Number of typos are " , num_typos)

# This returns a list of misspelt words
misspelt_words = checker.get_typos()
print("Misspelt words are " , misspelt_words)

# This returns a list of misspelt words excluding the words in the list
misspelt_words = checker.get_typos(exclude="lazi")
print("Misspelt words with exlusion are " , misspelt_words)

# This returns a list of misspelt words excluding the words in the list for the current instance
checker.exclude("browmn") # This excludes the word "browmn" for the whole instance
misspelt_words = checker.get_typos()
print("Misspelt words after using the exclude method first are " , misspelt_words)
```

Output:

```bash
{
"Total words": 9
"Number of misspelled words": 2
"Number of words in dictionary": 194433
"Misspelled words": ['browmn', 'lazi']
"Lookup time(s)": 0.0005731582641601562
}

Does the text have typos? True

Number of typos are 2

Misspelt words are ['browmn', 'lazi']

Misspelt words with exlusion are ['browmn']

Misspelt words after using the exclude method first are ['lazi']

```

# Contributing

We welcome contributions to this project, especially those that help us fix bugs, add new words or improve the docs. If you would like to contribute, please fork the repo and submit a pull request.

# Credits

Credits to [Harvard90873](https://github.com/Harvard90873/) for creating [spell-checker](https://pypi.org/project/spell-checker/) which is the base of this package.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "python-spell-checker",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "dev0cloo <etor.ocloo@gmail.com>",
    "keywords": "spell-check,spellchecker,typos",
    "author": "",
    "author_email": "dev0cloo <etor.ocloo@gmail.com>, Harvard90873 <harvard90873@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/d5/b8/09248c3c2967be4463c298b67cb104a13644e63be2a7be87e63c35f5c95c/python_spell_checker-1.1.0.tar.gz",
    "platform": null,
    "description": "# Python Spell Checker\n\nThe **spell checker** is a python package that can check your spelling. It supports **_6_** languages!\n\nIt contains the following languages:\n\n- English\n- German\n- Spanish\n- French\n- Italian\n- Code\n\n**_Code_** is a special language that contains the english language along with syntaxes and keywords of programming languages. This is to prevent the spell checker from marking them as misspelt words when the checker is used on a codebase. The words are stored in `code.txt` in `languages` folder.\n\nAll valid words of a language are stored in a text file in the `languages` folder. The words are sorted alphabetically and are in lowercase. You can add your own words to it. You can also delete words from the text file to exclude them as valid words.\n\n# Installation\n\nThe easiest way to install the package is to use `pip` or `pip3`:\n\n```bash\npip install python-spell-checker\n```\n\nor you can clone the repository and use the files:\n\n```bash\n    git clone https://github.com/dev0cloo/python-spell-checker.git\n    cd python-spell-checker\n```\n\n# Usage\n\nThe main file is `checker.py` in the `python_spell` folder.\n\nThe `SpellChecker` class is used to check the spelling of a text. It takes two arguments:\n\n- `text`: The text to be checked\n- `language`: The language of the text. It is set to `english` by default. The language must be one of the following:\n  - `english`\n  - `german`\n  - `spanish`\n  - `french`\n  - `italian`\n  - `code`\n\nThe `check()` method is used to check the spelling of the text. It returns a dictionary object with the following relevant keys:\n\n- `total_words`: The total number of words in the text\n- `misspelled_num`: The number of misspelled words in the text\n- `words_in_dictionary`: The number of words in the dictionary of the language\n- `misspelled_words`: A list of misspelled words\n\nThe `has_typos` attribute returns a boolean for if the text has typos or not.\n\nThe `number_of_typos()` method returns the number of typos in the text. It takes an optional argument `duplicates` which is set to `False` by default. If it is set to `True`, then each duplicate word is counted as a typo. If it is set to `False`, then each duplicate word is counted as a single typo.\n\nThe `get_typos()` method returns a list of misspelt words. It takes the optional arguments `duplicates` and `exclude`. `duplicates` is set to `False` by default and works the same as in `number_of_typos()`. `exclude` is a string or a list of strings that are excluded from the returned list of misspelt words. It is set to `None` by default.\n\n`exclude` can be used to exclude words that are not in the dictionary but are valid words without changing the language file. It takes an optional argument `temp` which is set to `False` by default. If it is set to `True`, then the words are excluded only for the current method call and not the whole instance. If it is set to `False`, then the words are excluded for the whole instance. This is useful if you want to exclude words for a single method call but not for the whole instance.\n\n#### Note\n\nThe SpellChecker class calls the `check()` method when it is initialized. So, you can directly use the `has_typos`, `number_of_typos()`, `get_typos()` and `exclude` methods without first calling the `check()` method. You can access the dictionary object returned by the `check()` method using the `checked` attribute.\n\n### Example:\n\n```Python\nfrom python_spell.checker import SpellChecker\ntext = \"The... ! quick browmn fox jumps-over the lazi dog\"\nchecker = SpellChecker(text, \"english\")\n\n# This returns a dictionary object with all information\ncheck_text = checker.checked\nprint(check_text)\n\n# This returns a boolean for if the text has typos or not\nis_valid = checker.has_typos\nprint(\"Does the text have typos? \" , is_valid)\n\n# This returns the number of typos (duplicate words are )\nnum_typos = checker.number_of_typos()\nprint(\"Number of typos are \" , num_typos)\n\n# This returns a list of misspelt words\nmisspelt_words = checker.get_typos()\nprint(\"Misspelt words are \" , misspelt_words)\n\n# This returns a list of misspelt words excluding the words in the list\nmisspelt_words = checker.get_typos(exclude=\"lazi\")\nprint(\"Misspelt words with exlusion are \" , misspelt_words)\n\n# This returns a list of misspelt words excluding the words in the list for the current instance\nchecker.exclude(\"browmn\") # This excludes the word \"browmn\" for the whole instance\nmisspelt_words = checker.get_typos()\nprint(\"Misspelt words after using the exclude method first are \" , misspelt_words)\n```\n\nOutput:\n\n```bash\n{\n\"Total words\": 9\n\"Number of misspelled words\": 2\n\"Number of words in dictionary\": 194433\n\"Misspelled words\": ['browmn', 'lazi']\n\"Lookup time(s)\": 0.0005731582641601562\n}\n\nDoes the text have typos? True\n\nNumber of typos are 2\n\nMisspelt words are ['browmn', 'lazi']\n\nMisspelt words with exlusion are ['browmn']\n\nMisspelt words after using the exclude method first are ['lazi']\n\n```\n\n# Contributing\n\nWe welcome contributions to this project, especially those that help us fix bugs, add new words or improve the docs. If you would like to contribute, please fork the repo and submit a pull request.\n\n# Credits\n\nCredits to [Harvard90873](https://github.com/Harvard90873/) for creating [spell-checker](https://pypi.org/project/spell-checker/) which is the base of this package.\n",
    "bugtrack_url": null,
    "license": "Copyright (c) 2021 Harvard90873  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Python spell checker library; supports English, German, Italian, Spanish, French, and even Code!",
    "version": "1.1.0",
    "project_urls": {
        "Homepage": "https://github.com/dev0cloo/python-spell-checker",
        "Repository": "https://github.com/dev0cloo/python-spell-checker"
    },
    "split_keywords": [
        "spell-check",
        "spellchecker",
        "typos"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "15f8335f77cb0bf9b2db5a630698a96e380d3614d0c9e9805f92b2f7f6557e70",
                "md5": "f7ed798284c0fe177edf0c1dff938b2f",
                "sha256": "686ce8f0a765e6724b1c0445d66998cf5ce3e38915ec23e8715b7c6a80dbdf81"
            },
            "downloads": -1,
            "filename": "python_spell_checker-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f7ed798284c0fe177edf0c1dff938b2f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 2711592,
            "upload_time": "2023-12-01T21:04:56",
            "upload_time_iso_8601": "2023-12-01T21:04:56.681985Z",
            "url": "https://files.pythonhosted.org/packages/15/f8/335f77cb0bf9b2db5a630698a96e380d3614d0c9e9805f92b2f7f6557e70/python_spell_checker-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d5b809248c3c2967be4463c298b67cb104a13644e63be2a7be87e63c35f5c95c",
                "md5": "5087823898d0d9c75da3f17d22527c5e",
                "sha256": "0276d6309be924689746cd7f0d92446b0cce03f78e0bf295613f872627ecfbb1"
            },
            "downloads": -1,
            "filename": "python_spell_checker-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "5087823898d0d9c75da3f17d22527c5e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 2722330,
            "upload_time": "2023-12-01T21:05:01",
            "upload_time_iso_8601": "2023-12-01T21:05:01.963666Z",
            "url": "https://files.pythonhosted.org/packages/d5/b8/09248c3c2967be4463c298b67cb104a13644e63be2a7be87e63c35f5c95c/python_spell_checker-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-01 21:05:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dev0cloo",
    "github_project": "python-spell-checker",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "python-spell-checker"
}
        
Elapsed time: 0.15125s