def pretrained_w2v(train_text, model, name):
    train_corpus = [text_to_word_sequence(text) for text in train_text]
    result = []
    for text in train_corpus:
        n_skip = 0
        vec = np.zeros(model.vector_size)
        for (n_w, word) in enumerate(text):
            if (word in model):
                vec = (vec + model.wv[word])
                continue
            word_ = word.upper()
            if (word_ in model):
                vec = (vec + model.wv[word_])
                continue
            word_ = word.capitalize()
            if (word_ in model):
                vec = (vec + model.wv[word_])
                continue
            word_ = ps.stem(word)
            if (word_ in model):
                vec = (vec + model.wv[word_])
                continue
            word_ = lc.stem(word)
            if (word_ in model):
                vec = (vec + model.wv[word_])
                continue
            word_ = sb.stem(word)
            if (word_ in model):
                vec = (vec + model.wv[word_])
                continue
            else:
                n_skip += 1
                continue
        vec = (vec / ((n_w - n_skip) + 1))
        result.append(vec)
    w2v_cols = ['{}{}'.format(name, i) for i in range(1, (model.vector_size + 1))]
    result = pd.DataFrame(result)
    result.columns = w2v_cols
    return result
def pretrained_w2v(train_text, model, name):
    train_corpus = [text_to_word_sequence(text) for text in train_text]
    result = []
    for text in train_corpus:
        n_skip = 0
        vec = np.zeros(model.vector_size)
        for (n_w, word) in enumerate(text):
            if (word in model):
                vec = (vec + model.wv[word])
                continue
            word_ = word.upper()
            if (word_ in model):
                vec = (vec + model.wv[word_])
                continue
            word_ = word.capitalize()
            if (word_ in model):
                vec = (vec + model.wv[word_])
                continue
            word_ = ps.stem(word)
            if (word_ in model):
                vec = (vec + model.wv[word_])
                continue
            word_ = lc.stem(word)
            if (word_ in model):
                vec = (vec + model.wv[word_])
                continue
            word_ = sb.stem(word)
            if (word_ in model):
                vec = (vec + model.wv[word_])
                continue
            else:
                n_skip += 1
                continue
        vec = (vec / ((n_w - n_skip) + 1))
        result.append(vec)
    w2v_cols = ['{}{}'.format(name, i) for i in range(1, (model.vector_size + 1))]
    result = pd.DataFrame(result)
    result.columns = w2v_cols
    return result