pip install PyDictionary

Requirement already satisfied: PyDictionary in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (2.0.1)
Requirement already satisfied: bs4 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from PyDictionary) (0.0.1)
Requirement already satisfied: goslate in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from PyDictionary) (1.5.4)
Requirement already satisfied: requests in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from PyDictionary) (2.31.0)
Requirement already satisfied: click in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from PyDictionary) (8.1.7)
Requirement already satisfied: beautifulsoup4 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from bs4->PyDictionary) (4.12.2)
Requirement already satisfied: soupsieve>1.2 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from beautifulsoup4->bs4->PyDictionary) (2.4.1)
Requirement already satisfied: futures in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from goslate->PyDictionary) (3.0.5)
Requirement already satisfied: certifi>=2017.4.17 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from requests->PyDictionary) (2023.7.22)
Requirement already satisfied: charset-normalizer<4,>=2 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from requests->PyDictionary) (3.2.0)
Requirement already satisfied: urllib3<3,>=1.21.1 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from requests->PyDictionary) (2.0.4)
Requirement already satisfied: idna<4,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from requests->PyDictionary) (3.4)
WARNING: You are using pip version 21.1.3; however, version 23.2.1 is available.
You should consider upgrading via the '/usr/local/bin/python3 -m pip install --upgrade pip' command.
Note: you may need to restart the kernel to use updated packages.
from PyDictionary import PyDictionary

# Initialize the PyDictionary
dictionary = PyDictionary()

# Function to fetch the meaning of a word
def fetch_meaning(word):
    try:
        meanings = dictionary.meaning(word)
        if meanings:
            for part_of_speech, definition_list in meanings.items():
                print(f"{part_of_speech}:")
                for definition in definition_list:
                    print(f"  - {definition}")
        else:
            print(f"Meaning not found for '{word}'")
    except Exception as e:
        print(f"An error occurred: {e}")

# Simple CLI interface for word lookup
while True:
    user_input = input("Enter a word to lookup (or 'exit' to quit): ").strip()
    
    if user_input.lower() == 'exit':
        break
    
    fetch_meaning(user_input)

Noun:
  - an expression of greeting
Verb:
  - affect with wonder
  - be a mystery or bewildering to
Adjective:
  - surprising greatly
  - inspiring awe or admiration or wonder
Meaning not found for ''
Meaning not found for ''
Meaning not found for ''
Meaning not found for ''