def calc_slor_scores(norm_lp_sub_scores: List[float],
lengths: List[int]) -> List[Union[None, float]]:
r"""Calculate SLOR (Syntactic Log-Odds Ratio)
.. math:
\frac{%
\log P_\text{model}\left(\xi\right)
- \log P_\text{unigram}\left(\xi\right)
}{%
\text{length}\left(\xi\right)
}
>>> '{:.3f}'.format(calc_slor_scores([20.8746], [4])[0])
'5.219'
"""
results = []
for norm_lp_sub_score, length in zip(norm_lp_sub_scores, lengths):
if (norm_lp_sub_score is None) or length == 0:
x = None
else:
x = norm_lp_sub_score / length
results.append(x)
return results
评论列表
文章目录