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
Recommended Answers
Jump to PostIt seems to me that there is an indention error at line 11. Line 11 should be in the
for b
loop.
Jump to PostIf you can attach
answer_token.txt
to a post, I could try the code.
Jump to PostBut what is the input file ?
All 9 Replies
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.