(fobj, is_dict=False)
return vocab
Read text and return dictionary that encodes vocabulary
Read text and return dictionary that encodes vocabulary
Read text and return dictionary that encodes vocabulary
def get_vocabulary(fobj, is_dict=False):
    """Read text and return dictionary that encodes vocabulary
    """
    vocab = Counter()
    for line in fobj:
        if is_dict:
            word, count = line.strip().split()
            vocab[word] = int(count)
        else:
            for word in line.split():
                vocab[word] += 1
    return vocab
def get_vocabulary ( fobj , is_dict = False ) : vocab = Counter ( ) for line in fobj : if is_dict : word , count = line . strip ( ) . split ( ) vocab [ word ] = int ( count ) else : for word in line . split ( ) : vocab [ word ] += 1 return vocab