preprocessing/embeddings.py
def convert_to_binary(embedding_path):
    """
    Here, it takes path to embedding text file provided by glove.
    :param embedding_path: takes path of the embedding which is in text format or any format other than binary.
    :return: a binary file of the given embeddings which takes a lot less time to load.
    """
    f = codecs.open(embedding_path + ".txt", 'r', encoding='utf-8')
    wv = []
    with codecs.open(embedding_path + ".vocab", "w", encoding='utf-8') as vocab_write:
        count = 0
        for line in f:
            if count == 0:
                pass
            else:
                splitlines = line.split()
                vocab_write.write(splitlines[0].strip())
                vocab_write.write("\n")
                wv.append([float(val) for val in splitlines[1:]])
            count += 1
    np.save(embedding_path + ".npy", np.array(wv))

    Here, it takes path to embedding text file provided by glove.
    :param embedding_path: takes path of the embedding which is in text format or any format other than binary.
    :return: a binary file of the given embeddings which takes a lot less time to load.
    
Here, it takes path to embedding text file provided by glove.
Here it takes path to embedding text file provided by glove .
def convert_to_binary(embedding_path):
    f = codecs.open(embedding_path + ".txt", 'r', encoding='utf-8')
    wv = []
    with codecs.open(embedding_path + ".vocab", "w", encoding='utf-8') as vocab_write:
        count = 0
        for line in f:
            if count == 0:
                pass
            else:
                splitlines = line.split()
                vocab_write.write(splitlines[0].strip())
                vocab_write.write("\n")
                wv.append([float(val) for val in splitlines[1:]])
            count += 1
    np.save(embedding_path + ".npy", np.array(wv))
def convert_to_binary ( embedding_path ) : f = codecs . open ( embedding_path + ".txt" , 'r' , encoding = 'utf-8' ) wv = [ ] with codecs . open ( embedding_path + ".vocab" , "w" , encoding = 'utf-8' ) as vocab_write : count = 0 for line in f : if count == 0 : pass else : splitlines = line . split ( ) vocab_write . write ( splitlines [ 0 ] . strip ( ) ) vocab_write . write ( "\n" ) wv . append ( [ float ( val ) for val in splitlines [ 1 : ] ] ) count += 1 np . save ( embedding_path + ".npy" , np . array ( wv ) )
Here, it takes path to embedding text file provided by glove.
Here it takes path to embedding text file provided by glove .
"""
    Here, it takes path to embedding text file provided by glove.
    :param embedding_path: takes path of the embedding which is in text format or any format other than binary.
    :return: a binary file of the given embeddings which takes a lot less time to load.
    """
a binary file of the given embeddings which takes a lot less time to load.
a binary file of the given embeddings which takes a lot less time to load .
embedding_path
takes path of the embedding which is in text format or any format other than binary.
takes path of the embedding which is in text format or any format other than binary .