Sunday, November 17, 2024
Google search engine
HomeLanguagesenchant.list_languages() in Python

enchant.list_languages() in Python

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.dict_exists()

enchant.list_languages() is an inbuilt method of enchant module. It is used to list the languages for which the dictionaries are available.

Syntax : enchant.list_languages()

Parameter : Nothing

Returns : a list of language codes for which dictionaries are available

Example 1:




# import the enchant module
import enchant
  
# list the languages for which
# dictionaries are available
print(enchant.list_languages())


Output :

[‘en_BW’, ‘en_AU’, ‘en_BZ’, ‘en_GB’, ‘en_JM’, ‘en_DK’, ‘en_HK’, ‘en_GH’, ‘en_US’, ‘en_ZA’, ‘en_ZW’, ‘en_SG’, ‘en_NZ’, ‘en_BS’, ‘en_AG’, ‘en_PH’, ‘en_IE’, ‘en_NA’, ‘en_TT’, ‘en_IN’, ‘en_NG’, ‘en_CA’]

Example 2: Verify thar all the language codes generated by enchant.list_languages() exist in enchant or not using enchant.dict_exists().




# import the enchant module
import enchant
  
for lang in enchant.list_languages():
    if enchant.dict_exists(lang):
        print("The dictionary for " + lang + " exists.")
    else:
        print("The dictionary for " + lang + " does not exists.")


Output :

The dictionary for en_BW exists.
The dictionary for en_AU exists.
The dictionary for en_BZ exists.
The dictionary for en_GB exists.
The dictionary for en_JM exists.
The dictionary for en_DK exists.
The dictionary for en_HK exists.
The dictionary for en_GH exists.
The dictionary for en_US exists.
The dictionary for en_ZA exists.
The dictionary for en_ZW exists.
The dictionary for en_SG exists.
The dictionary for en_NZ exists.
The dictionary for en_BS exists.
The dictionary for en_AG exists.
The dictionary for en_PH exists.
The dictionary for en_IE exists.
The dictionary for en_NA exists.
The dictionary for en_TT exists.
The dictionary for en_IN exists.
The dictionary for en_NG exists.
The dictionary for en_CA exists.

Last Updated :
26 May, 2020
Like Article
Save Article

<!–

–>

Similar Reads
Related Tutorials
Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments