English Dictionary in Python

If you need to check, whether a particular word is a word in the English dictionary, you can do it in Python.

What you need to do first, is to install the enchant module with PIP.

This is a simple example of how you can use this module:

First, we have to import the enchant module.

A next line is a dict object called my_dict. It represents the language directory. The language is represented by the tag “en”. The dialects are represented by the additional uppercase tag. In our case it’s  “US”, but can also be “AU” etc.

You can also use this line of code, with the language only.

When you run this code, you are going to get the following result:

['compute', 'computers', 'computes', 'computed', 'commuter', 'compute r']
['compute', 'computer', 'computing']

The first line shows that the program recognizes the word “computer” as an English word and prints TRUE. The next one has a typo, therefore it’s not recognized by a program as an English word and returns FALSE.

The suggest function gives you a list of words similar to the word given as a parameter.

It also does it for the word with a typo. One of the suggestions is probably what we wanted.