Beispiel #1
0
import Word2Vec
import gensim
import numpy as np
import pymysql.cursors

# ===========================================
# load data
connection = pymysql.connect(user='******', password='******', database='GRE')
cursor = connection.cursor()
commit = "select * from GRES"
cursor.execute(commit)
Sentences = [each[1] for each in cursor.fetchall()]
Sentences = Word2Vec.cleanText(Sentences)

# ===========================================
# Load model
model_google = gensim.models.Word2Vec.load_word2vec_format(
    '../model/GoogleNews-vectors-negative300.bin', binary=True)
# Word2Vec.Train_Wrod2VEc(Sentences, model_google)

# ===========================================
# Generalize words
n_dim = 300
train_vectors = [
    Word2Vec.buildWordVector(model_google, z, n_dim) for z in Sentences
]
Word2Vec.storeVecs(train_vectors, '../vectors/google_vecs.txt')
Beispiel #2
0
import gensim
import pymysql.cursors

import Word2Vec

# ===========================================
# load data
connection = pymysql.connect(user='******', password='******', database='GRE')
cursor = connection.cursor()
commit = "select * from GRES"
cursor.execute(commit)
Sentences = [each[1] for each in cursor.fetchall()]
Sentences = Word2Vec.cleanText(Sentences)

# ===========================================
# Load model
model_google = gensim.models.KeyedVectors.load_word2vec_format('../GoogleModel/GoogleNews-vectors-negative300.bin', binary=True)
# Word2Vec.Train_Wrod2VEc(Sentences, model_google)

# ===========================================
# Generalize words
n_dim = 300
train_vectors = [Word2Vec.buildWordVector(model_google, z, n_dim) for z in Sentences]
Word2Vec.storeVecs(train_vectors, '../data for input/word_vecs.pkl')
import Word2Vec

# ===========================================
# load data
connection = pymysql.connect(user='******', password='******', database='GRE')
cursor = connection.cursor()
commit = "select * from GRES2"
cursor.execute(commit)
Sentences = [each[1] for each in cursor.fetchall()]
Sentences = Word2Vec.cleanText(Sentences)

# ===========================================
# Load model
model_google = gensim.models.KeyedVectors.load_word2vec_format('../GoogleModel/GoogleNews-vectors-negative300.bin', binary=True)
# Word2Vec.Train_Wrod2VEc(Sentences, model_google)

# ===========================================
# Generalize words
n_dim = 300
train_vectors = [Word2Vec.buildWordVector(model_google, z, n_dim) for z in Sentences]
Word2Vec.storeVecs(train_vectors, '../data for input1/q_vecs.pkl')

commit = "select * from GRES2"
cursor.execute(commit)
Sentences = [each[2] for each in cursor.fetchall()]
Sentences = Word2Vec.cleanText(Sentences)

# Generalize words
train_vectors = [Word2Vec.buildWordVector(model_google, z, n_dim) for z in Sentences]
Word2Vec.storeVecs(train_vectors, '../data for input1/a_vecs.pkl')
Beispiel #4
0
import Word2Vec
import gensim
import numpy as np
import pymysql.cursors

# ===========================================
# load data
connection = pymysql.connect(user='******', password='******', database='GRE')
cursor = connection.cursor()
commit = "select * from GRES"
cursor.execute(commit)
Sentences = [each[1] for each in cursor.fetchall()]
Sentences = Word2Vec.cleanText(Sentences)

# ===========================================
# Train model
model_w2v = gensim.models.Word2Vec.load('../model/model_w2v')
Word2Vec.Train_Wrod2VEc(Sentences, model_w2v)

# ===========================================
# Generalize words
n_dim = 300
train_vectors = [
    Word2Vec.buildWordVector(model_w2v, z, n_dim) for z in Sentences
]
Word2Vec.storeVecs(train_vectors, '../model/w2v_vecs.txt')