-
Notifications
You must be signed in to change notification settings - Fork 3
/
word_w2v.py
28 lines (18 loc) · 656 Bytes
/
word_w2v.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
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import pickle
import gensim, logging
with open('data/tweets_list.pickle',mode='rb') as ff:
tweets=pickle.load(ff)
tweetchars=[t.lower().split() for t in tweets]
print(len(tweets))
print(tweetchars[0])
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
model = gensim.models.Word2Vec(tweetchars,size=8, window=25, min_count=5, workers=5)
print(model['a'])
print(model['e'])
print(model['?'])
print(model.most_similar(positive=['a']))
print(model.most_similar(positive=['e']))
print(model.most_similar(positive=['?']))
model.save('models/word2vec_word.model')