简体   繁体   中英

How do I find a synonym of a word or multi-word paraphrase using the gensim toolkit

在使用gensim工具包加载了经过预训练的word2vec模型后,我想在给定诸如“她是个聪明人”这样聪明的语境下找到一个单词的同义词。

There's a method [most_similar()][1] that will report the words of the closest vectors, by cosine-similarity in the model's coordinates, to a given word. For example:

similars = loaded_w2v_model.most_similar('bright')

However, Word2vec won't find strictly synonyms – just words that were contextually-related in its training-corpus. These are often synonym-like, but also can be similar in other ways – such as used in the same topical domains, or able to replace each other functionally. (In that last respect, sometimes the highly-similar word-vectors are for antonyms , because words like 'hot' and 'cold' appear in the same places, referring the the same aspect of something.)

Plain word2vec also doesn't deal with polysemy (that a token like 'bright' is both a word for 'well-lit' and a word for 'smart') well. So the list of most-similar words for 'bright' will include a mix from its alternate senses.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM