word2vec / README.md
cool9203's picture
Create README.md
bba35b9 verified
metadata
language:
  - zh

Word2vec

Train script

https://github.com/zake7749/word2vec-tutorial

Dataset

wiki-zh_tw 2022/12

Use

import gensim
import jieba
import numpy as np

sentence = "今天天氣真好"
words = jieba.cut(sentence, cut_all=False)

model = gensim.models.KeyedVectors.load(str(Path(path, "model.kv")))

word_vec = list()
for word in words:
  word_vec.append(model.get_vector(word, norm=True))

sentence_vec = np.array(word_vec, dtype="float32").mean(0)