def main(args): dec_dir = join(args.decode_dir, 'output') with open(join(args.decode_dir, 'log.json')) as f: split = json.loads(f.read())['split'] ref_dir = join(args.data_dir, 'refs', split) assert exists(ref_dir) if args.rouge: dec_pattern = r'(\d+).dec' ref_pattern = '#ID#.ref' output = eval_rouge(dec_pattern, dec_dir, ref_pattern, ref_dir, rouge_path=args.rouge_path) metric = 'rouge' else: dec_pattern = '[0-9]+.dec' ref_pattern = '[0-9]+.ref' output = eval_meteor(dec_pattern, dec_dir, ref_pattern, ref_dir, meteor_path=args.meteor_path) metric = 'meteor' print(output) with open(join(args.decode_dir, '{}.txt'.format(metric)), 'w') as f: f.write(output)
def main(args): dec_dir = args.decode_dir ref_dir = join(_REF_DIR, 'reference') if args.rouge: dec_pattern = r'(\d+).dec' ref_pattern = '#ID#.ref' output = eval_rouge(dec_pattern, dec_dir, ref_pattern, ref_dir) else: dec_pattern = '[0-9]+.dec' ref_pattern = '[0-9]+.ref' output = eval_meteor(dec_pattern, dec_dir, ref_pattern, ref_dir) print(output)
def main(args): dec_dir = args.decode_file ref_dir = args.ref_file assert exists(ref_dir) if args.rouge: output = eval_rouge(dec_dir, ref_dir) metric = 'rouge' else: output = eval_meteor(dec_dir, ref_dir) metric = 'meteor' print(output) with open('{}.txt'.format(metric), 'w') as f: f.write(output)
def main(args): dec_dir = join(args.decode_dir, 'output') with open(join(args.decode_dir, 'log.json')) as f: split = json.loads(f.read())['split'] ref_dir = join(_DATA_DIR, 'refs', split) assert exists(ref_dir) if args.rouge: dec_pattern = r'(\d+).dec' ref_pattern = '#ID#.ref' output = eval_rouge(dec_pattern, dec_dir, ref_pattern, ref_dir, force=args.force) metric = 'rouge' elif args.meteor: dec_pattern = '[0-9]+.dec' ref_pattern = '[0-9]+.ref' output = eval_meteor(dec_pattern, dec_dir, ref_pattern, ref_dir, force=args.force) metric = 'meteor' elif args.novel_ngrams: eval_novel_ngrams_args = { 'data_dir': join(_DATA_DIR, split), 'data_pattern': '[0-9]+.json', 'dec_dir': dec_dir, 'dec_pattern': '[0-9]+.dec', 'ref_dir': ref_dir, 'ref_pattern': '[0-9]+.ref', } output = json.dumps(eval_novel_ngrams(**eval_novel_ngrams_args), indent=4, ensure_ascii=False) metric = 'novel-ngrams' else: raise NotImplementedError() print(output) with open(join(args.decode_dir, '{}.txt'.format(metric)), 'w') as f: f.write(output)
def main(args): dec_dir = join(args.decode_dir, 'output') with open(join(args.decode_dir, 'log.json')) as f: split = json.loads(f.read())['split'] ref_dir = join(_DATA_DIR, 'refs', split) assert exists(ref_dir) if args.rouge: dec_pattern = r'(\d+).dec' ref_pattern = '#ID#.ref' output = eval_rouge(dec_pattern, dec_dir, ref_pattern, ref_dir) metric = 'rouge' else: dec_pattern = '[0-9]+.dec' ref_pattern = '[0-9]+.ref' output = eval_meteor(dec_pattern, dec_dir, ref_pattern, ref_dir) metric = 'meteor' print(output) with open(join(args.decode_dir, '{}.txt'.format(metric)), 'w') as f: f.write(output)
def main(args): dec_dir = join(args.decode_dir, 'output_top{}'.format(args.n_ext)) if not exists(dec_dir): make_summaries(args.decode_dir, args.n_ext) with open(join(args.decode_dir, 'log.json')) as f: split = json.loads(f.read())['split'] ref_dir = join(_DATA_DIR, 'refs', split) assert exists(ref_dir) if args.rouge: dec_pattern = r'(\d+).dec' ref_pattern = '#ID#.ref' output = eval_rouge(dec_pattern, dec_dir, ref_pattern, ref_dir) metric = 'rouge' else: dec_pattern = '[0-9]+.dec' ref_pattern = '[0-9]+.ref' output = eval_meteor(dec_pattern, dec_dir, ref_pattern, ref_dir) metric = 'meteor' print(output) with open(join(args.decode_dir, 'top{}_{}.txt'.format(args.n_ext, metric)), 'w') as f: f.write(output)