(vocab_dir)
return cat_to_id, id_to_cat
:return:
def cat_2_id(vocab_dir):
    """

    :return:
    """
    with open(vocab_dir) as f:
        categories = [_.strip() for _ in f.readlines()]
    cat_to_id = dict(zip(categories, range(len(categories))))
    id_to_cat = dict((v, k) for k, v in cat_to_id.items())

    return cat_to_id, id_to_cat
def cat_2_id ( vocab_dir ) : with open ( vocab_dir ) as f : categories = [ _ . strip ( ) for _ in f . readlines ( ) ] cat_to_id = dict ( zip ( categories , range ( len ( categories ) ) ) ) id_to_cat = dict ( ( v , k ) for k , v in cat_to_id . items ( ) ) return cat_to_id , id_to_cat