Get similar words suggestion using Enchant in Python
Last Updated :
14 Apr, 2018
For the given user input, get similar words through Enchant module.
Enchant
is a module in python which is used to check the spelling of a word, gives suggestions to correct words. Also, gives antonym and synonym of words. It checks whether a word exists in dictionary or not. Other dictionaries can also be added, as, (“en_UK”), (“en_CA”), (“en_GB”) etc.
To install enchant :
pip install pyenchant
Examples :
Input : Helo
Output : Hello, Help, Hero, Helot, Hole
Input : Trth
Output : Truth, Trash, Troth, Trench
Below is the implementation :
import enchant
d = enchant. Dict ( "en_US" )
word = input ( "Enter word: " )
d.check(word)
print (d.suggest(word))
|
Output :
Enter word: aple
['pale', 'ale', 'ape', 'maple', 'ample', 'apple', 'plea', 'able', 'apse']
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...