Table of Contents
Example Description
Expand your vocabulary and enhance your writing with the Synonyms and Antonyms Word Converter.

Introduction

The Synonyms and Antonyms Word Converter is a powerful tool powered by the ChatGPT extension that allows users to effortlessly find synonyms and antonyms for words. It harnesses the capabilities of the advanced language model to provide accurate and contextually relevant word alternatives.

With the Synonyms and Antonyms Word Converter, you can expand your vocabulary, enhance your writing, and improve your communication skills. Whether you’re a writer seeking more expressive language or a student looking to diversify your word choices, this tool is designed to assist you in finding suitable alternatives quickly and easily.

Using the ChatGPT extension, the Synonyms and Antonyms Word Converter engage in interactive conversations, making it an intuitive and user-friendly tool. By providing a word as input, you can receive a list of synonyms or antonyms, depending on your preference, helping you to diversify your language and convey your ideas with precision.

Code

sprite = Sprite('Tobi')
gpt = ChatGPT()
str2 = ""
var2=""

sprite.input("Please provide a word for which you would like to find synonyms and antonyms")
answer= str(sprite.answer())

gpt.getsynonymsAntonymsfromText("Synonyms",answer)
str1=gpt.chatGPTresult()


for i in str1:
    if not i.isdigit():
        str2 += i
        
print("Synonyms words are:", str2)

gpt.getsynonymsAntonymsfromText("Antonyms",answer)
var1=gpt.chatGPTresult()

for j in var1:
    if not j.isdigit():
        var2 += j
        
print("Antonyms words are:", var2)

Logic

  1. Open PictoBlox and select the environment as appropriate Python Coding Environment.
  2. Create a new file.
  3. Select the environment as appropriate Python Coding Environment.
  4. First, an instance of the Sprite class is created, with the name “Tobi”.
  5. To add the ChatGPT extension, click on the extension button located as shown in the image. This will enable the ChatGPT extension, allowing you to incorporate its capabilities into your project.
  6. Two empty strings, str2 and var2, are declared to store the resulting synonyms and antonyms, respectively.
  7. The user is prompted to provide a word for which they want to find synonyms and antonyms using the input() method from the Sprite library.
  8. The user’s input is stored in the answer variable as a string.
  9. The getsynonymsAntonymsfromText() method is called on the gpt object to find synonyms for the provided word. The category “Synonyms” is specified.
  10. The resulting synonyms are obtained from gpt.chatGPTresult() and stored in the str1 variable.
  11. The code then iterates over each character in str1 and appends non-digit characters to str2, filtering out any numerical values.
  12. Finally, the code prints the extracted synonyms stored in str2.
  13. The process is repeated for finding antonyms, where the getsynonymsAntonymsfromText() method is called with the category “Antonyms“, and the resulting antonyms are stored in the var1 variable.
  14. Non-digit characters are extracted and stored in var2, which contains the antonyms.
  15. The code concludes by printing the extracted antonyms stored in var2.
  16. Press Run to run the code.
  17. Sprite Tobi asks for the word you want synonyms/antonyms for.
  18. Go to the terminal. the terminal will display the synonyms and antonyms for a word.

Output