important_dic = {'预付卡'}
weight = 3 #可以修改,也可以再字典里添加权值
k=0
for word in set(sent):
if word in important_dic:
k = weight
else:
k = 0
if word in dic:
index = dic.index(word)
vec[index] = 1+k
print(word)
else:
print(word + 'is not in vocabulary!! Will ignore this word!!')
continue
list = model.wv.most_similar(word, topn=n)
for tuple in list:
word = tuple[0]
similarity = tuple[1]+k
# similarity = 1
#print(tuple)
index = dic.index(word)
vec[index] = similarity
增加了权重,进行权重增加的词会在相似度匹配中获得较大的影响力