Last Updated : 05 Sep, 2024
AyDictionaryIt's a Python module used to fetch definitions of words, while googletrans provides translation services.
To install AyDictionary run the following
pip
code on the terminal / command prompt:
pip install AyDictionary googletrans==4.0.0-rc1Getting Started
Now let us see how to use the AyDictionary module. First of all we need to import the module:
from AyDictionary import AyDictionary
After importing the module, we need to create an instance of it in order to use it:
dictionary = AyDictionary()
To get the meaning of a word we need to pass the word in the
meaning()
method
Example
Python
# Get the meaning of "python"
meaning = dictionary.meaning("python")
print(f"Meaning of 'python':")
print(meaning)
Output:
Meaning of 'python':Using googletrans
{'Noun': ['large Old World boas', 'a soothsaying spirit or a person who is possessed by such a spirit', '(Greek mythology']}
googletrans provides translations of words into different languages.
Import the Module Python
from googletrans import Translator
Create a Translator Instance Python
translator = Translator()
Translate a Word
Use the translate() method to get translations.
Python
# Translate "happy" to German
translation = translator.translate("happy", dest="de")
print(f"\nTranslation of 'happy' to German:")
print(translation.text)
Output:
glücklich
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4