generator.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:frame-generator 作者: jlonij 项目源码 文件源码
def save_settings(args, output_dir):
    '''
    Save settings to file.
    '''
    if args['gtype'] == 'topics':
        output_args = ['gtype', 'dlen', 'tcount', 'tsize', 'mallet']
    elif args['gtype'] == 'keywords' or args['gtype'] == 'frames':
        output_args = ['gtype', 'dlen', 'kmodel', 'kcount', 'ktags']
        if args['kmodel'] == 'lda':
            output_args += ['tcount', 'tsize', 'mallet']
        if args['gtype'] == 'frames':
            output_args += ['wdir', 'wsize', 'fsize', 'ftags']

    with open(output_dir + os.sep + 'settings' + '.csv', 'wb') as f:
        # Manually encode a BOM, utf-8-sig didn't work with unicodecsv
        f.write(u'\ufeff'.encode('utf8'))
        csv_writer = csv.writer(f, delimiter='\t', encoding='utf-8')
        for arg in output_args:
            csv_writer.writerow([arg, str(args[arg])])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号