Ejemplo n.º 1
0
def recursive_expanduser(obj):
    if isinstance(obj, dict):
        for key, value in obj.items():
            obj[key] = recursive_expanduser(value)
    elif isinstance(obj, str) and obj.startswith('~/'):
        obj = PathManager.expanduser(obj)
    elif isinstance(obj, list):
        for i, val in enumerate(obj):
            if isinstance(val, str) and val.startswith('~/'):
                obj[i] = PathManager.expanduser(val)
    return obj
Ejemplo n.º 2
0
 def save_lang_dict():
     src_file = PathManager.expanduser("~/clcdsa/astbert/data-mmap/lang.jsonl")
     dict = Dictionary.load(src_file)
     tgt_file = os.path.join(args['preprocess']['destdir'], 'lang.jsonl')
     PathManager.mkdir(os.path.dirname(tgt_file))
     dict.save(tgt_file)
     return dict