9

I 'm working on word2vec model using gensim in Python, but I found that the result are the words having the same theme, synonyms are only part of the result.

Can I find synonyms of a word based on the work I have done?

Any replies will be appreciated!

Royan
  • 133
  • 1
  • 2
  • 7

2 Answers2

9

Word2vec tends to indicate similar words – but as you've probably seen, the kind of similarity it learns includes more than just pure synonyms.

For example, word2vec similarities include words that appear in similar contexts, such as alternatives including even opposites. (After all, 'hot' and 'cold' are very similar words in many ways – both adjectives, primarily relating to temperature, and also figuratively used in the same sorts of non-temperature contexts. Only in their contrast are they antonyms.)

You'll likely need to use other techniques (perhaps in concert with word2vec) for pure-synonym discovery.

gojomo
  • 52,260
  • 14
  • 86
  • 115
  • 1
    Yes, I wonder what "other techniques" is. anyway, Thanks for your reply! – Royan Jun 13 '17 at 02:43
  • 3
    [automatic synonym identification] or [automatic synonym extraction] would be good queries to find academic papers proposing approaches – and one that surveys some approaches that include the use of word embeddings is . There's also another SO answer about the general task at https://stackoverflow.com/questions/11370247/methods-for-automated-synonym-detection – gojomo Jun 13 '17 at 04:02
  • I will try these, Thanks a lot! – Royan Jun 20 '17 at 09:20
1
import nltk
import gensim

nltk.download('word2vec_sample')

word2vec_sample = str(find('models/word2vec_sample/pruned.word2vec.txt'))

model = gensim.models.KeyedVectors.load_word2vec_format(word2vec_sample, binary=False)

top=model.most_similar(positive=['cricket'], topn = 3)

print(top)
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
Jalal md
  • 11
  • 1
  • 2
    Code is a lot more helpful when it is accompanied by an explanation. Stack Overflow is about learning, not providing snippets to blindly copy and paste. Please [edit] your question and explain how it answers the specific question being asked. See [answer]. – ChrisGPT was on strike Nov 18 '21 at 02:29
  • Where to import `find()` ? – Amit Pathak Nov 15 '22 at 05:50