这是我的代码:
similarity_score = []
for sentence1 in text:
for sentence2 in text:
if sentence1!=sentence2:
sim_score = []
temp2 = []
sim = [[wn.word_similarity(word1,word2,'jcn') for word1 in sentence1] for word2 in sentence2]
# s_sim = sum([sum(i) for i in zip(*sim)])
s_sim = sum(sum_similarity(sim))
sim_score.append(s_sim)
# C_sim = content_sim(sentence1,sentence2)
# sim_score.append(C_sim)
# t_sim = sum([e/max(sim_score) for e in sim_score])
t_sim = sum(sim_score)/len(sim_score)
temp2.append(sentence1)
temp2.extend((sentence2,t_sim))
similarity_score.append(temp2)
return similarity_score
我遇到以下错误:
文件“ C:\ Users \ Waqar Ahmad \ projects \ website \ website \ pages \ Sentence_similarity.py“,第83行, 相似地 s_sim = sum(sum_likeity(sim))TypeError:'NoneType'对象不可迭代[12 / Sep / 2019 22:02:51]“ POST / genericbased_similaritymatrix HTTP / 1.1“ 500 371830