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
- Open PictoBlox and select the environment as appropriate Python Coding Environment.
- Create a new file.
- Select the environment as appropriate Python Coding Environment.
- First, an instance of the Sprite class is created, with the name “Tobi”.
- 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.
- Two empty strings, str2 and var2, are declared to store the resulting synonyms and antonyms, respectively.
- 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.
- The user’s input is stored in the answer variable as a string.
- The getsynonymsAntonymsfromText() method is called on the gpt object to find synonyms for the provided word. The category “Synonyms” is specified.
- The resulting synonyms are obtained from gpt.chatGPTresult() and stored in the str1 variable.
- The code then iterates over each character in str1 and appends non-digit characters to str2, filtering out any numerical values.
- Finally, the code prints the extracted synonyms stored in str2.
- 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.
- Non-digit characters are extracted and stored in var2, which contains the antonyms.
- The code concludes by printing the extracted antonyms stored in var2.
- Press Run to run the code.
- Sprite Tobi asks for the word you want synonyms/antonyms for.
- Go to the terminal. the terminal will display the synonyms and antonyms for a word.
Output