Skip to content

Instantly share code, notes, and snippets.

@strubell
Last active May 17, 2018 18:13
Show Gist options
  • Save strubell/ccd091237d63eee939c0710242cde8fd to your computer and use it in GitHub Desktop.
Save strubell/ccd091237d63eee939c0710242cde8fd to your computer and use it in GitHub Desktop.
with open(os.devnull, 'w') as devnull:
try:
srl_eval = check_output(["perl", "bin/srl-eval.pl", srl_gold_fname, srl_preds_fname], stderr=devnull)
print(srl_eval)
overall_f1 = float(srl_eval.split('\n')[6].split()[-1])
correct['F1'] = overall_f1
except CalledProcessError as e:
print("Call to eval failed: %s" % e.output)
with open(os.devnull, 'w') as devnull:
try:
parse_eval = check_output(["perl", "bin/eval.pl", "-g", parse_gold_fname, "-s", parse_pred_fname], stderr=devnull)
short_str = parse_eval.split('\n')[:3]
print('\n'.join(short_str))
print('\n')
correct['parse_eval'] = parse_eval
correct['LAS'] = short_str[0].split()[9]
correct['UAS'] = short_str[1].split()[9]
except CalledProcessError as e:
print("Call to parse eval failed: %s" % e.output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment