This program is to find similarities between the a sentences and words
and how they are similar in synonyms
I have downloaded the nltk
when i first coded it was run and there were no errors but after some days when i run the program ti give me this error AttributeError: 'list' object has no attribute '_all_hypernyms'
the error is because of this wn.wup_similarity
import nltk
from nltk.tokenize import word_tokenize
from nltk.corpus import stopwords
from nltk.corpus import wordnet as wn
database=[]
main_sen=[]
words=[]
range_is=[0.78]
word_check=[0.1]
main_sentence="the world in ending with the time is called hello"
database_word=["known","complete"]
stopwords = stopwords.words('english')
words = word_tokenize(main_sentence)
filtered_sentences = []
for word in words:
if word not in stopwords:
filtered_sentences.append(word)
print (filtered_sentences)
for databasewords in database_word:
database.append(wn.synsets(databasewords)[0])
print(database)
for sentences in filtered_sentences:
main_sen.append(wn.synsets(sentences))
print(main_sen)
# Error is in below lines
for data in database:
for sen in main_sen :
word_check.append(wn.wup_similarity(data,sen))
if word_check >range_is:
count = +1
print(count)