def t_error(row):
"""func to calcuate the edit distance of a translation from the original sentence
only works when called from df.apply"""
if row[e] is not None:
return ed.eval(row['sentence'], row[e])
else:
return None
def apply_scores(data=data):
"""takes in a dataframe and adds a score column for each translation"""
for e in list(speech_engines.keys()):
data[f'{e}_score'] = data.apply(t_error, axis=1)
return data
data = apply_scores(data)
data