def glove2word2vec(glove_input_file, word2vec_output_file):
 (num_lines, num_dims) = get_glove_info(glove_input_file)
 logger.info('converting %i vectors from %s to %s', num_lines, glove_input_file, word2vec_output_file)
 if (sys.version_info < (3,)):
  with smart_open(word2vec_output_file, 'wb') as fout:
   fout.write(('%s %s\n' % (num_lines, num_dims)))
   with smart_open(glove_input_file, 'rb') as fin:
    for line in fin:
     fout.write(line)
  return (num_lines, num_dims)
 else:
  with smart_open(word2vec_output_file, 'w') as fout:
   fout.write(('%s %s\n' % (num_lines, num_dims)))
   with smart_open(glove_input_file, 'r') as fin:
    for line in fin:
     fout.write(line)
  return (num_lines, num_dims)

def glove2word2vec ( glove_input_file , word2vec_output_file ) : ( num_lines , num_dims ) = get_glove_info ( glove_input_file ) logger . info ( 'converting %i vectors from %s to %s' , num_lines , glove_input_file , word2vec_output_file ) if ( sys . version_info < ( 3 , ) ) : with smart_open ( word2vec_output_file , 'wb' ) as fout : fout . write ( ( '%s %s\n' % ( num_lines , num_dims ) ) ) with smart_open ( glove_input_file , 'rb' ) as fin : for line in fin : fout . write ( line ) return ( num_lines , num_dims ) else : with smart_open ( word2vec_output_file , 'w' ) as fout : fout . write ( ( '%s %s\n' % ( num_lines , num_dims ) ) ) with smart_open ( glove_input_file , 'r' ) as fin : for line in fin : fout . write ( line ) return ( num_lines , num_dims )
convert glove_input_file in glove format into word2vec_output_file in word2vec format .