import codecs


def get_freq_dict(filename, encoding='utf-8'):
    """ Get tag frequencies 
    
    filename: file with words/tags, one sentence per line 
    
    returns freq_dict: a dictionary from word/tag to frequency 
    """

    freq_dict = dict()    
    with codecs.open(filename, encoding=encoding) as f:
        for line in f:
            for t in line.strip().split():
                freq_dict[t] = freq_dict.get(t, 0) + 1
    return freq_dict