如何使用 FastText 查找相似的单词? [英] How to find similar words with FastText?
问题描述
我正在玩 FastText
,https://pypi.python.org/pypi/fasttext,与 Word2Vec
非常相似.由于它似乎是一个相当新的库,还没有多少内置函数,我想知道如何提取形态相似的词.
I am playing around with FastText
, https://pypi.python.org/pypi/fasttext,which is quite similar to Word2Vec
. Since it seems to be a pretty new library with not to many built in functions yet, I was wondering how to extract morphological similar words.
例如:model.similar_word("dog")
-> 狗.但是没有内置函数.
For eg: model.similar_word("dog")
-> dogs. But there is no function built-in.
如果我输入model["dog"]
我只得到了可能用于比较余弦相似度的向量.model.cosine_similarity(model["dog"], model["dogs"]])
.
I only get the vector, that might be used to compare cosine similarity.
model.cosine_similarity(model["dog"], model["dogs"]])
.
我是否必须进行某种循环并对文本中的所有可能对执行 cosine_similarity
?这需要时间......!!!
Do I have to make some sort of loop and do cosine_similarity
on all possible pairs in a text? That would take time ...!!!
推荐答案
使用 Gensim,使用 load.word2vec 模型加载 fastText 训练好的 .vec 文件,并使用 most_similiar() 方法查找相似词!
Use Gensim, load fastText trained .vec file with load.word2vec models and use most_similiar() method to find similar words!
这篇关于如何使用 FastText 查找相似的单词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!