-
Notifications
You must be signed in to change notification settings - Fork 2
/
boxplotter.py
28 lines (23 loc) · 947 Bytes
/
boxplotter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import argparse
import matplotlib.pyplot as plt
plt.style.use("ggplot")
parser = argparse.ArgumentParser(description="Run the plotter")
parser.add_argument("-f", "--file-name", type=str, help="filename to be plotted")
args = parser.parse_args()
bscore, mscore = [], []
with open(args.file_name, 'r') as the_file:
for line in the_file.readlines():
if line.startswith("Cumulative BLEU4"):
_, score = line.split(':')
bscore.append(float(score.strip()))
elif line.startswith("Cumulative METEOR"):
_, score = line.split(':')
mscore.append(float(score.strip()))
print(f"[BLEU4] max: {max(bscore)}, min: {min(bscore)}, avg: {sum(bscore)/len(bscore)}")
print(f"[METEOR] max: {max(mscore)}, min: {min(mscore)}, avg: {sum(mscore)/len(bscore)}")
plt.boxplot(bscore)
plt.title("BLEU4 score distribution")
plt.show()
plt.boxplot(mscore)
plt.title("METEOR score distribution")
plt.show()