(line, vocab)
return bag
returns bag of words representation of given phrase using given vocab

    Args:
        line: string representing phrase to be parsed
        vocab: dictionary with words as keys and indices as values

    Return:
        integer list
returns bag of words representation of given phrase using given vocab
returns bag of words representation of given phrase using given vocab
def bag_of_words(line, vocab):
    '''returns bag of words representation of given phrase using given vocab

    Args:
        line: string representing phrase to be parsed
        vocab: dictionary with words as keys and indices as values

    Return:
        integer list
    '''
    bag = [0]*len(vocab)
    words = split_line(line)
    for w in words:
        if w in vocab:
            bag[vocab[w]] += 1
    return bag
def bag_of_words ( line , vocab ) : bag = [ 0 ] * len ( vocab ) words = split_line ( line ) for w in words : if w in vocab : bag [ vocab [ w ] ] += 1 return bag