Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to get synonyms of a word in python

import nltk
from nltk.corpus import wordnet   #Import wordnet from the NLTK
syn = list()
ant = list()
for synset in wordnet.synsets("Worse"):
   for lemma in synset.lemmas():
      syn.append(lemma.name())    #add the synonyms
      if lemma.antonyms():    #When antonyms are available, add them into the list
      ant.append(lemma.antonyms()[0].name())
print('Synonyms: ' + str(syn))
print('Antonyms: ' + str(ant))
Comment

PREVIOUS NEXT
Code Example
Python :: if string contains list of letters python 
Python :: AttributeError: __enter__ python 
Python :: measure execution time in ipython notebook 
Python :: python get os 
Python :: python ssh connection 
Python :: how to use dictionary comprehension to make a dictionary for some names of a list in python 
Python :: current date to epoch python 
Python :: remove 1st column pandas 
Python :: numpy normalize 
Python :: python cut string after character 
Python :: Python program to get the file size of a plain file. 
Python :: python dictonary of dictonary 
Python :: ipython save session 
Python :: python: calculate number of days from today date in a data frame 
Python :: pywhatkit 
Python :: change directory in python script 
Python :: pandas replace substring in column names 
Python :: how to hide turtle in python 
Python :: python send get request with headers 
Python :: assignment 7.1 python data structures 
Python :: create dictionary from input python 
Python :: how to detect if the space button is pressed in pygame 
Python :: only size-1 arrays can be converted to Python scalars 
Python :: how to sum only the even values in python 
Python :: CSRF verification failed. Request aborted. 
Python :: round to the nearest integer python 
Python :: pyspark overwrite schema 
Python :: how to read excel file in python 
Python :: python sort two key 
Python :: import csv from google drive python 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =