-
Notifications
You must be signed in to change notification settings - Fork 6
/
test_vector.py
34 lines (27 loc) · 912 Bytes
/
test_vector.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
# _*_ coding: utf-8 _*_
"""
@description:
@Time : 18/1/5 上午1:10
@Author : guomianzhuang
"""
import logging
import os
import multiprocessing
from gensim.models import Word2Vec
from gensim.models.word2vec import LineSentence
# inp = "/Users/Matthew/Documents/workspace/NER-Master-zhuang/word2vec/wiki.zh.model"
# outp = "/Users/Matthew/Documents/workspace/NER-Master-zhuang/word2vec/wiki.zh.vec"
inp = "/Users/Matthew/Documents/workspace/NER-Master-zhuang/word2vec/finance.model"
outp = "/Users/Matthew/Documents/workspace/NER-Master-zhuang/word2vec/finance.vec"
def save_vector():
model = Word2Vec.load(inp)
model.wv.save_word2vec_format(outp, binary=False)
def test_model():
model = Word2Vec.load(inp)
rs = model.most_similar(u"人工智能")
for e in rs:
print(e[0], e[1])
if __name__ == '__main__':
test_model()
# save_vector()