def closest(self, w, n=10):
"""
Assumes the vectors have been normalized.
"""
if self.oov(w):
return []
scores = self.m.dot(self.represent(w).T).T.tocsr()
return heapq.nlargest(n, zip(scores.data, [self.iw[i] for i in scores.indices]))
评论列表
文章目录