import numpy as np
# infile="/opt/tiger/sumtest/crossLingualTransfer/utils/analyzeCrossLingual/outs/inner.clean"

# average_scores = []
# fin = open(infile, 'r')
# for k in range(1, 21):
#     average = []
#     for lg in ['en', 'zh', 'fr']:
#         score = fin.readline().strip().replace("Retrieval Acc: ", "")
#         average.append(float(score))
#     average_scores.append("{:.3f}".format(np.average(average)))
# fin.close()

# fout = open("inner_score.txt", 'w')
# log_out = "\t".join(average_scores)
# fout.write(log_out + '\n')
# fout.close()

infile="/opt/tiger/sumtest/crossLingualTransfer/utils/analyzeCrossLingual/outs/retrieval.clean"

fr_average_scores = []
zh_average_scores = []
fin = open(infile, 'r')
for k in range(1, 21):
    average = []
    for lg in ['en-zh', 'en-fr']:
        score = fin.readline().strip().replace("Retrieval Acc: ", "")
        if lg == "en-fr":
            fr_average_scores.append("{:.3f}".format(float(score)))
        else:
            zh_average_scores.append("{:.3f}".format(float(score)))
fin.close()

fout = open("retrieval_score.txt", 'w')
log_out = "\t".join(fr_average_scores)
fout.write("fr\n" + log_out + '\n')
log_out = "\t".join(zh_average_scores)
fout.write("zh\n" + log_out + '\n')
fout.close()