Package: python-spell-checker
Python Spell CheckerThespell checkeris a python package that can check your spelling. It supports6languages!It contains the following languages:EnglishGermanSpanishFrenchItalianCodeCodeis 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 incode.txtinlanguagesfolder.All valid words of a language are stored in a text file in thelanguagesfolder. 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.InstallationThe easiest way to install the package is to usepiporpip3:pipinstallpython-spell-checkeror you can clone the repository and use the files:gitclonehttps://github.com/dev0cloo/python-spell-checker.gitcdpython-spell-checkerUsageThe main file ischecker.pyin thepython_spellfolder.TheSpellCheckerclass is used to check the spelling of a text. It takes two arguments:text: The text to be checkedlanguage: The language of the text. It is set toenglishby default. The language must be one of the following:englishgermanspanishfrenchitaliancodeThecheck()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 textmisspelled_num: The number of misspelled words in the textwords_in_dictionary: The number of words in the dictionary of the languagemisspelled_words: A list of misspelled wordsThehas_typosattribute returns a boolean for if the text has typos or not.Thenumber_of_typos()method returns the number of typos in the text. It takes an optional argumentduplicateswhich is set toFalseby default. If it is set toTrue, then each duplicate word is counted as a typo. If it is set toFalse, then each duplicate word is counted as a single typo.Theget_typos()method returns a list of misspelt words. It takes the optional argumentsduplicatesandexclude.duplicatesis set toFalseby default and works the same as innumber_of_typos().excludeis a string or a list of strings that are excluded from the returned list of misspelt words. It is set toNoneby default.excludecan be used to exclude words that are not in the dictionary but are valid words without changing the language file. It takes an optional argumenttempwhich is set toFalseby default. If it is set toTrue, then the words are excluded only for the current method call and not the whole instance. If it is set toFalse, 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.NoteThe SpellChecker class calls thecheck()method when it is initialized. So, you can directly use thehas_typos,number_of_typos(),get_typos()andexcludemethods without first calling thecheck()method. You can access the dictionary object returned by thecheck()method using thecheckedattribute.Example:frompython_spell.checkerimportSpellCheckertext="The... ! quick browmn fox jumps-over the lazi dog"checker=SpellChecker(text,"english")# This returns a dictionary object with all informationcheck_text=checker.checkedprint(check_text)# This returns a boolean for if the text has typos or notis_valid=checker.has_typosprint("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 wordsmisspelt_words=checker.get_typos()print("Misspelt words are ",misspelt_words)# This returns a list of misspelt words excluding the words in the listmisspelt_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 instancechecker.exclude("browmn")# This excludes the word "browmn" for the whole instancemisspelt_words=checker.get_typos()print("Misspelt words after using the exclude method first are ",misspelt_words)Output:{"Total words":9"Number of misspelled words":2"Number of words in dictionary":194433"Misspelled words":['browmn','lazi']"Lookup time(s)":0.0005731582641601562}Doesthetexthavetypos?True

Numberoftyposare2Misspeltwordsare['browmn','lazi']Misspeltwordswithexlusionare['browmn']Misspeltwordsafterusingtheexcludemethodfirstare['lazi']ContributingWe 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.CreditsCredits toHarvard90873for creatingspell-checkerwhich is the base of this package.