I am using this code to get all synonyms from the text in document named "answer_tokens.txt" it is only listing the words in the document without the synonyms. can someone check it out?
from nltk.corpus import wordnet
with open('answer_tokens.txt') as a: #opening the tokenised answer file
wn_tokens = (a.read())
#printing the answer tokens word by word as opened
print('==========================================')
synonyms = []
for b in word_tokenize(wn_tokens):
print (str (b))
for syn in wordnet.synsets (b):
for l in syn.lemmas(b):
synonyms.append(l.name())
influx 0 Newbie Poster
Gribouillis 1,391 Programming Explorer Team Colleague
influx 0 Newbie Poster
Gribouillis 1,391 Programming Explorer Team Colleague
influx 0 Newbie Poster
Gribouillis 1,391 Programming Explorer Team Colleague
influx 0 Newbie Poster
influx 0 Newbie Poster
Gribouillis 1,391 Programming Explorer Team Colleague
influx 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.