How to convert a text file by word2vec using python

638 views Asked by At

I am beginner of python language,natural language processing,deep learning,neural networks.I want to execute a program which convert text file into vector by using word2vec in python..someone please help me

import math 
import nltk file = "/home/stephy/Demo/textfile.txt" 
import numpy as np 

def loadGloveModel(gloveFile): 
    with open(gloveFile, encoding="utf8" ) as f: 
        content = f.readlines() 
    model = {} for line in content: 
        splitLine = line.split() 
        word = splitLine[0] 
    embedding = np.array([float(val) for val in splitLine[1:]])  
    model[word] = embedding 
    print ("Done.",len(model)," words loaded!") 
    return model 

model= loadGloveModel(file) 
print (model['file']) 
0

There are 0 answers