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.
enchant.request_dict()
enchant.request_dict() is an inbuilt method of enchant module. It is used to get a dictionary object for a specific language.
Syntax : enchant.request_dict(tag) Parameter : tag : code of the language Returns : a Dict object
Example 1 :
Python3
# import the enchant module import enchant # dictionary of en_US d = enchant.request_dict("en_US") # the dictionary tag tag = d.tag print ("The dictionary tag is " + tag) |
The dictionary tag is en_US
Example 2 : When the enchant.request_dict() method is executed without passing any parameter in it, it by default takes the code of the language of the local machine.
Python3
# import the enchant module import enchant # instantiating the dictionary # without passing any parameter d = enchant.request_dict() # finding the dictionary tag tag = d.tag print ("The dictionary tag is " + tag) |
The dictionary tag is en_IN
Example 3 : The enchant.request_dict() method may fail if the appropriate dictionary is not available. In that case the following message is printed:
Python3
enchant.request_dict() |
Output :
Traceback (most recent call last): File “”, line 1, in enchant.request_dict() File “C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\enchant\__init__.py”, line 272, in request_dict return Dict(tag, self) File “C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\enchant\__init__.py”, line 541, in __init__ _EnchantObject.__init__(self) File “C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\enchant\__init__.py”, line 144, in __init__ self._init_this() File “C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\enchant\__init__.py”, line 548, in _init_this this = self._broker._request_dict_data(self.tag) File “C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\enchant\__init__.py”, line 286, in _request_dict_data self._raise_error(e_str % (tag, ), DictNotFoundError) File “C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\enchant\__init__.py”, line 233, in _raise_error raise eclass(default) enchant.errors.DictNotFoundError: Dictionary for language ‘English_India’ could not be found