nltk工具计算bleu score
作者:
Nevrast | 来源:发表于
2020-06-17 11:27 被阅读0次from nltk.translate import bleu_score
class Bleu(object):
def __init__():
self.smooth_fun = bleu_score.SmoothingFunction()
def tokenize(string):
""" Specific tokenzation method need to be defined """
raise NotImplementedError
def score(hypothesis, references):
"""
hypothesis: string from model output
references: a list of strings as ground truth
"""
return bleu_score.sentence_bleu(references, hypothesis, weights=(0.5, 0.5),
smoothing_function=self.smooth_fun.method2)
本文标题:nltk工具计算bleu score
本文链接:https://www.haomeiwen.com/subject/utigmhtx.html
网友评论