How to Check Spellings of Given Words using Enchant in PythonPython has a module named Enchant, which is used for checking the spellings of the word and giving suggestions for corrections. It also gives options for antonym and synonym of the words. It can also check in the dictionary if a word exists or not. The check() function returns "true" if the given the word is present in the language dictionary; otherwise, it will return "false". We can also use this functionality of the check() function for checking the spelling of the words. In Enchant module, we can also use suggest() function for correcting spellings of the incorrectly spelled word. In this tutorial, we will see an example to understand the usage of Enchant module in Python for checking in spellings of the given the word and suggestions for correct spellings. Installation:To install Enchant module, we can use the following command: Output: Collecting pyenchant Downloading pyenchant-3.2.2-py3-none-win_amd64.whl (11.9 MB) Installing collected packages: pyenchant Successfully installed pyenchant-3.2.2 Example: To check the spelling of the words and get suggestions for corrections Output: The misspelled words in the list are : ['Cer', 'Peaple', 'Dronk', 'Beur', 'Plut'] Suggestion for misspelledCer : ['Ce', 'Cr', 'Er', 'Cher', 'Cerf', 'Ser', 'Ter', 'Cor', 'Cdr', 'Der', 'Ger', 'Per', 'Chr', 'Her', 'Yer'] Suggestion for misspelledPeaple : ['Peale', 'People', 'Leaper', 'Plea'] Suggestion for misspelledDronk : ['Cronk', 'Drink', 'Drone', 'Drank', 'Drunk', 'Drongo'] Suggestion for misspelledBeur : ['Bur', 'Beer', 'Bear', 'Blur', 'Eur'] Suggestion for misspelledPlut : ['Pluto', 'Slut', 'Prut', 'Glut', 'Pl ut', 'Pl-ut', 'Plur', 'Put', 'Plus', 'Plat', 'Plot', 'Pout', 'Plug', 'Plum'] ConclusionIn this tutorial, we discussed how to install, and use Enchant module for checking the spellings of the given words and get suggestions for misspelled words. |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India