def flatten_json(file, proc_func):
'''A multi-processing wrapper for loading SQuAD data file.'''
with open(file) as f:
data = json.load(f)['data']
with ProcessPoolExecutor(max_workers=args.threads) as executor:
rows = executor.map(proc_func, data)
rows = sum(rows, [])
return rows
评论列表
文章目录