chatopera / Synonyms

:herb: 中文近义词:聊天机器人,智能问答工具包
https://bot.chatopera.com/
Other
5.02k stars 904 forks source link

wv模型库中不存在词的相似度处理 #38

Closed AlexSun1995 closed 6 years ago

AlexSun1995 commented 6 years ago

description

如果分词的结果在WV的模型库中不存在, 返回的结果是全0的向量

current

  try:
           c.append(_vectors.word_vec(y_))
  except KeyError as error:
           print("not exist in w2v model: %s" % y_)
           c.append(np.zeros((100,), dtype=float))

expected

如果待比较的两个词在模型库中都不存在,返回的结果都会是同样的向量, 二者之间的距离就会很近.而事实上二者之间的关系可能并不大

solution

可以考虑返回随机向量(以token 的hashcode为seed)

environment

hailiang-wang commented 6 years ago

这个想法很好,能帮忙做一个PR么?

AlexSun1995 commented 6 years ago

好的