Suppose I have a loop
which executes like the following:-
for i in range(len(X_test)):
_, _, ref, hyp = result([X_test[i]],y_test.iloc[i])
hyp = hyp.replace('<end>', '')
bleu_score = bleu([ref], hyp, smoothing_function=cc.method3)
print("Associated BLEU score:",bleu_score,"\n")
overall_bleu.append(bleu_score)
What I would like to do is create a new CSV file, with 2 columns i.e. Reference (Stands for ref variable in the loop)
and Predicted (Stands for hyp variable in the loop)
such that for each row, at every successive iteration of the loop, the strings hyp
and ref
are written to corresponding columns of a new CSV file (which I would like to create). Any clean way of doing this? I was thinking to use Pandas
, but seems it will be redundant to write every time within the loop.