Skip to content

Latest commit

 

History

History
59 lines (38 loc) · 2.09 KB

Python_Get_Word_Definition_and_Translation.md

File metadata and controls

59 lines (38 loc) · 2.09 KB



Template request | Bug report | Generate Data Product

Tags: #python #dictionary #project #word #snippet

Author: Sriniketh Jayasendil

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))