(sentences, model, unseen=None)
return np.array(vec)
Generate vectors for each sentence (list) in a list of sentences. Vector is simply a
    sum of vectors for individual words.
    
    Parameters
    ----------
    sentences : list, array
        List with sentences
    model : word2vec.Word2Vec
        Gensim word2vec model
    unseen : None, str
        Keyword for unseen words. If None, those words are skipped.
        https://stats.stackexchange.com/questions/163005/how-to-set-the-dictionary-for-text-analysis-using-neural-networks/163032#163032

    Returns
    -------
    np.array
Generate vectors for each sentence (list) in a list of sentences. Vector is simply a
    sum of vectors for individual words.
    
    Parameters
    ----------
    sentences : list, array
        List with sentences
    model : word2vec.Word2Vec
        Gensim word2vec model
    unseen : None, str
        Keyword for unseen words. If None, those words are skipped.
        https://stats.stackexchange.com/questions/163005/how-to-set-the-dictionary-for-text-analysis-using-neural-networks/163032#163032
Generate vectors for each sentence ( list ) in a list of sentences . Vector is simply a sum of vectors for individual words . Parameters ---------- sentences : list array List with sentences model : word2vec . Word2Vec Gensim word2vec model unseen : None str Keyword for unseen words . If None those words are skipped . https : // stats . stackexchange . com / questions / 163005 / how - to - set - the - dictionary - for - text - analysis - using - neural - networks / 163032#163032
def sentences2vec(sentences, model, unseen=None):
    """Generate vectors for each sentence (list) in a list of sentences. Vector is simply a
    sum of vectors for individual words.
    
    Parameters
    ----------
    sentences : list, array
        List with sentences
    model : word2vec.Word2Vec
        Gensim word2vec model
    unseen : None, str
        Keyword for unseen words. If None, those words are skipped.
        https://stats.stackexchange.com/questions/163005/how-to-set-the-dictionary-for-text-analysis-using-neural-networks/163032#163032

    Returns
    -------
    np.array
    """
    keys = set(model.wv.vocab.keys())
    vec = []
    if unseen:
        unseen_vec = model.wv.word_vec(unseen)

    for sentence in sentences:
        if unseen:
            vec.append(sum([model.wv.word_vec(y) if y in set(sentence) & keys
                       else unseen_vec for y in sentence]))
        else:
            vec.append(sum([model.wv.word_vec(y) for y in sentence 
                            if y in set(sentence) & keys]))
    return np.array(vec)
def sentences2vec ( sentences , model , unseen = None ) : keys = set ( model . wv . vocab . keys ( ) ) vec = [ ] if unseen : unseen_vec = model . wv . word_vec ( unseen ) for sentence in sentences : if unseen : vec . append ( sum ( [ model . wv . word_vec ( y ) if y in set ( sentence ) & keys else unseen_vec for y in sentence ] ) ) else : vec . append ( sum ( [ model . wv . word_vec ( y ) for y in sentence if y in set ( sentence ) & keys ] ) ) return np . array ( vec )