Links
Comment on page

Get Word Definition and Translation

Tags: #python #dictionary #project #word #snippet
Last update: 2023-04-12 (Created: 2022-10-18)
Description: This notebook get world definition and translation from English using PyDictionary.

Input

Import libraries

try:
from PyDictionary import PyDictionary
except ModuleNotFoundError:
!pip install PyDictionary
from PyDictionary import PyDictionary

Setup Variables

  • Enter the word in English
  • Check the available language codes here
word = input("-> Enter the word to get all details: ") # Get the word from the user
lang_code = input(
"-> Enter the language that needs to be translated: "
) # Available language codes: https://developers.google.com/admin-sdk/directory/v1/languages [EN, FR, ES]

Model

Set PyDictionary

dictionary = PyDictionary() # Create a PyDictionary Model

Output

Meaning

print(word + " : ", end="")
meaning = dictionary.meaning(word)
print(meaning) # replace "earth" with any other word of your choice

Translate

print(word + " => " + dictionary.translate(word, lang_code))