Home » Python » python – How to learn word2vec model-Exceptionshub

python – How to learn word2vec model-Exceptionshub

Posted by: admin February 24, 2020 Leave a comment


I want to use word2vec, but when I enter the code below I get an error.

KeyError: “word ‘정부’ not in vocabulary”

I don’t know how to deal with it.

Can you help me?

from gensim.models.word2vec import Word2Vec import pandas as pd

df = pd.read_csv('https://raw.githubusercontent.com/DoosanB/files/master/test.csv', encoding = 'utf-8') df = pd.DataFrame(df)

model = Word2Vec(df['corpus'].values, sg=1, window=5, min_count=1, workers=4, iter=100)

model_result1 = model.wv.most_similar("정부")
How to&Answers:

With the most_similar method you can learn what are the similarity among words within the corpus. In that sense, make sure that what you are passing to most_simillar is actually in the corpus.