Open In App

AyDictionary Module in Python

Last Updated : 21 Aug, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

AyDictionary is a Python 3–compatible library for fetching word meanings, synonyms, and antonyms. It’s a modern alternative to PyDictionary, which often fails in Python 3. When combined with googletrans, you can also translate words easily in your Python programs.

Installation

To install AyDictionary and googletrans, run the following command:

pip install AyDictionary googletrans==4.0.0-rc1

Getting Started with AyDictionary

1. Import the Module

First, import the AyDictionary class into your program:

Python
from AyDictionary import AyDictionary

2. Create an Instance

To use AyDictionary, create an instance of it:

Python
dictionary = AyDictionary()

This object will let you call methods like meaning(), synonym() and antonym().

3. Fetch the Meaning of a Word

meaning() method returns the definitions of a given word. This is useful when building dictionary-like apps or educational tools.

Python
# Get the meaning of "python"
meaning = dictionary.meaning("python")
print(f"Meaning of 'python':")
print(meaning)

Output:

Meaning of 'python':

{'Noun': ['large Old World boas',

'a soothsaying spirit or a person who is possessed by such a spirit',

'(Greek mythology)']}

4. Fetch Synonyms

synonym() method provides a list of synonyms (similar words). This is useful for writing-assist tools, word games, or enhancing vocabulary.

Python
synonyms = dictionary.synonym("happy")
print(f"Synonyms of 'happy': {synonyms}")

Output:

Synonyms of 'happy': ['content', 'joyful', 'cheerful']

5. Fetch Antonyms

antonym() method returns a list of antonyms (opposite words). Great for learning and natural language processing tasks where contrasts are important.

Python
antonyms = dictionary.antonym("happy")
print(f"Antonyms of 'happy': {antonyms}")

Output:

Antonyms of 'happy': ['sad', 'unhappy', 'miserable']

Using AyDictionary with googletrans

Sometimes you may also want to translate words into different languages. For this, you can combine AyDictionary with googletrans, a free and simple translation library.

Python
from googletrans import Translator
translator = Translator()

# Translate "happy" to German
translation = translator.translate("happy", dest="de")
print(f"Translation of 'happy' to German: {translation.text}")

Output:

glücklich


Article Tags :

Explore