增加权重
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
增加了權重,進行權重增加的詞會在相似度匹配中獲得較大的影響力
轉載于:https://www.cnblogs.com/yjybupt/p/9953599.html
總結
- 上一篇: 中老年的微信网名大全
- 下一篇: 银子的价格是多少?