import re


def wv_mapping(row, wv):
    """
    Maps each word of phrase to word2vec model value
    :param row: row containing each phrase
    :param wv: the word2vec model
    :return: mapped words i.e. array for each word from wv
    """
    row_mapping = []
    for word in row.split():
        word = re.sub('[^A-Za-z0-9]+', '', word) # remove special chars like ?
        try:
            row_mapping.append(wv.get_vector(word.lower()))
        except:
            # this looks after stop words and for any word that is not in our wv model
            # we add a null array for such case
            row_mapping.append([0] * wv.vector_size)
    return row_mapping