How to get synonyms of a particular word from wordnet.
Wordnet It is nothing but the lexical database or we can say dictionary for English language which is specifically desined for NLP (natuaral language processing). To look up words in wordnet a special kind of a simple interface is present in the NLTK library i.e Synset which is nothing but "sets of cognitive synonyms".
WordNet hastily looks like a thesaurus, in that it bunches words together dependent on their implications. It additionally interlinks the word structures series of letters as well as explicit feelings of words. WordNet marks the semantic relationship among words, though the groupings of words in a thesaurus don't follow any unequivocal example other than significance similitude.
from nltk.corpus import wordnet
My_sysn = wordnet.synsets("fight")
Here we are going to find synonyms for "Write" word.
print("Print an Example of the word:",My_sysn.name(), "\n")
print("Print just the word:", My_sysn.lemmas().name(),"\n")
print("Definition of word:", My_sysn.definition(),'\n')
print("Examples of the word in use in sentences:",My_sysn.examples())
Print an Example of the word: battle.n.01 Print just the word: battle Definition of word: a hostile meeting of opposing military forces in the course of a war Examples of the word in use in sentences: ['Grant won a decisive victory in the battle of Chickamauga', 'he lost his romantic ideas about war when he got into a real engagement']